[libvirt] [PATCH] fix build erro when building with --without-libvirtd

--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-) diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; }; -# ifdef WITH_LIBVIRTD typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name); diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..38e4f6e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -885,8 +885,76 @@ int virStateStop(void) { return ret; } -#endif +#else /* WITH_LIBVIRTD */ + +/** + * virRegisterStateDriver: + * @driver: pointer to a driver block + * + * Register a virtualization driver + * + * Returns the driver priority or -1 in case of error. + */ +int +virRegisterStateDriver(virStateDriverPtr driver ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateInitialize: + * @privileged: set to true if running with root privilege, false otherwise + * @callback: callback to invoke to inhibit shutdown of the daemon + * @opaque: data to pass to @callback + * + * Initialize all virtualization drivers. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateInitialize(bool privileged ATTRIBUTE_UNUSED, + virStateInhibitCallback callback ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateCleanup: + * + * Run each virtualization driver's cleanup method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateCleanup(void) +{ + return 0; +} + +/** + * virStateReload: + * + * Run each virtualization driver's reload method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateReload(void) +{ + return 0; +} + +/** + * virStateStop: + * + * Run each virtualization driver's "stop" method. + * + * Returns 0 if successful, -1 on failure + */ +int virStateStop(void) +{ + return 0; +} +#endif /* WITH_LIBVIRTD */ /** diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 595d2db..b82f6b9 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,7 +27,6 @@ # include "internal.h" -# ifdef WITH_LIBVIRTD typedef void (*virStateInhibitCallback)(bool inhibit, void *opaque); @@ -37,7 +36,6 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); -# endif /* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. -- 1.8.0.1.240.ge8a1f5a

On 02/04/2013 09:23 AM, Hu Tao wrote:
--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
Even though this is a solution and it makes the calls to virState* never fail during compilation, I see the other approach being used as well in some files (xen _driver.c for example): #ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; #endif I like this a bit more, but that's just a subjective opinion. However, if you go with your approach, I'd rather see it cleaning up those paths as well.
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..38e4f6e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -885,8 +885,76 @@ int virStateStop(void) { return ret; }
-#endif +#else /* WITH_LIBVIRTD */ + +/** + * virRegisterStateDriver: + * @driver: pointer to a driver block + * + * Register a virtualization driver + * + * Returns the driver priority or -1 in case of error. + */ +int +virRegisterStateDriver(virStateDriverPtr driver ATTRIBUTE_UNUSED) +{ + return 0; +} +
The comment is false in this case, so I'd keep the comments to a minimum and just mention that these are just dummy functions. [...] Martin

On Mon, Feb 04, 2013 at 12:25:48PM +0100, Martin Kletzander wrote:
On 02/04/2013 09:23 AM, Hu Tao wrote:
--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
Even though this is a solution and it makes the calls to virState* never fail during compilation, I see the other approach being used as well in some files (xen _driver.c for example):
#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; #endif
I like this a bit more, but that's just a subjective opinion. However, if you go with your approach, I'd rather see it cleaning up those paths as well.
Agreed, pretty much all cases of 'WITH_LIBVIRTD' should be removed from files under the src/ directory. 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 :|

On Mon, Feb 04, 2013 at 12:25:48PM +0100, Martin Kletzander wrote:
On 02/04/2013 09:23 AM, Hu Tao wrote:
--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
Even though this is a solution and it makes the calls to virState* never fail during compilation, I see the other approach being used as well in some files (xen _driver.c for example):
#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; #endif
I like this a bit more, but that's just a subjective opinion. However, if you go with your approach, I'd rather see it cleaning up those paths as well.
See. Thanks for review. -- Regards, Hu Tao

On Mon, Feb 04, 2013 at 04:23:30PM +0800, Hu Tao wrote:
--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..38e4f6e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -885,8 +885,76 @@ int virStateStop(void) { return ret; }
-#endif +#else /* WITH_LIBVIRTD */ + +/** + * virRegisterStateDriver: + * @driver: pointer to a driver block + * + * Register a virtualization driver + * + * Returns the driver priority or -1 in case of error. + */ +int +virRegisterStateDriver(virStateDriverPtr driver ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateInitialize: + * @privileged: set to true if running with root privilege, false otherwise + * @callback: callback to invoke to inhibit shutdown of the daemon + * @opaque: data to pass to @callback + * + * Initialize all virtualization drivers. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateInitialize(bool privileged ATTRIBUTE_UNUSED, + virStateInhibitCallback callback ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateCleanup: + * + * Run each virtualization driver's cleanup method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateCleanup(void) +{ + return 0; +} + +/** + * virStateReload: + * + * Run each virtualization driver's reload method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateReload(void) +{ + return 0; +} + +/** + * virStateStop: + * + * Run each virtualization driver's "stop" method. + * + * Returns 0 if successful, -1 on failure + */ +int virStateStop(void) +{ + return 0; +}
Don't add all these stubs - just remove the WITH_LIBVIRTD conditional from the original impls. There is nothing that prevents us building them, even if libvirtd is disabled 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 :|

On Mon, Feb 04, 2013 at 11:43:59AM +0000, Daniel P. Berrange wrote:
On Mon, Feb 04, 2013 at 04:23:30PM +0800, Hu Tao wrote:
--- src/driver.h | 4 --- src/libvirt.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++- src/libvirt_internal.h | 2 -- 3 files changed, 69 insertions(+), 7 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..38e4f6e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -885,8 +885,76 @@ int virStateStop(void) { return ret; }
-#endif +#else /* WITH_LIBVIRTD */ + +/** + * virRegisterStateDriver: + * @driver: pointer to a driver block + * + * Register a virtualization driver + * + * Returns the driver priority or -1 in case of error. + */ +int +virRegisterStateDriver(virStateDriverPtr driver ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateInitialize: + * @privileged: set to true if running with root privilege, false otherwise + * @callback: callback to invoke to inhibit shutdown of the daemon + * @opaque: data to pass to @callback + * + * Initialize all virtualization drivers. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateInitialize(bool privileged ATTRIBUTE_UNUSED, + virStateInhibitCallback callback ATTRIBUTE_UNUSED, + void *opaque ATTRIBUTE_UNUSED) +{ + return 0; +} + +/** + * virStateCleanup: + * + * Run each virtualization driver's cleanup method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateCleanup(void) +{ + return 0; +} + +/** + * virStateReload: + * + * Run each virtualization driver's reload method. + * + * Returns 0 if all succeed, -1 upon any failure. + */ +int virStateReload(void) +{ + return 0; +} + +/** + * virStateStop: + * + * Run each virtualization driver's "stop" method. + * + * Returns 0 if successful, -1 on failure + */ +int virStateStop(void) +{ + return 0; +}
Don't add all these stubs - just remove the WITH_LIBVIRTD conditional from the original impls. There is nothing that prevents us building them, even if libvirtd is disabled
Okey, I see. I'll send v2. -- Regards, Hu Tao

Don't check WITH_LIBVIRTD in C source files because we will build the sources even without libvirtd. --- src/driver.h | 4 ---- src/libvirt.c | 7 ------- src/libvirt_internal.h | 2 -- src/remote/remote_driver.c | 6 ------ src/xen/xen_driver.c | 6 +----- 5 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; }; -# ifdef WITH_LIBVIRTD typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name); diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..e2a7b5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -118,10 +118,8 @@ static virSecretDriverPtr virSecretDriverTab[MAX_DRIVERS]; static int virSecretDriverTabCount = 0; static virNWFilterDriverPtr virNWFilterDriverTab[MAX_DRIVERS]; static int virNWFilterDriverTabCount = 0; -#ifdef WITH_LIBVIRTD static virStateDriverPtr virStateDriverTab[MAX_DRIVERS]; static int virStateDriverTabCount = 0; -#endif #if defined(POLKIT_AUTH) @@ -771,7 +769,6 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; } -#ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: * @driver: pointer to a driver block @@ -885,10 +882,6 @@ int virStateStop(void) { return ret; } -#endif - - - /** * virGetVersion: * @libVer: return value for the library version (OUT) diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 595d2db..b82f6b9 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,7 +27,6 @@ # include "internal.h" -# ifdef WITH_LIBVIRTD typedef void (*virStateInhibitCallback)(bool inhibit, void *opaque); @@ -37,7 +36,6 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); -# endif /* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 341321b..354a216 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -156,7 +156,6 @@ static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr /* Helper functions for remoteOpen. */ static char *get_transport_from_scheme(char *scheme); -#ifdef WITH_LIBVIRTD static int remoteStartup(bool privileged ATTRIBUTE_UNUSED, virStateInhibitCallback callback ATTRIBUTE_UNUSED, @@ -168,7 +167,6 @@ remoteStartup(bool privileged ATTRIBUTE_UNUSED, inside_daemon = true; return 0; } -#endif #ifndef WIN32 /** @@ -6382,12 +6380,10 @@ static virNWFilterDriver nwfilter_driver = { }; -#ifdef WITH_LIBVIRTD static virStateDriver state_driver = { .name = "Remote", .initialize = remoteStartup, }; -#endif /** remoteRegister: @@ -6408,9 +6404,7 @@ remoteRegister(void) if (virRegisterDeviceMonitor(&dev_monitor) == -1) return -1; if (virRegisterSecretDriver(&secret_driver) == -1) return -1; if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1; -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif return 0; } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 2795ebc..d65f4a6 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -91,7 +91,7 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif }; -#if defined WITH_LIBVIRTD || defined __sun +#ifdef __sun static bool inside_daemon = false; #endif @@ -200,7 +200,6 @@ done: return res; } -#ifdef WITH_LIBVIRTD static int xenInitialize(bool privileged ATTRIBUTE_UNUSED, @@ -216,7 +215,6 @@ static virStateDriver state_driver = { .initialize = xenInitialize, }; -#endif /*----- Dispatch functions. -----*/ @@ -2398,9 +2396,7 @@ static virDriver xenUnifiedDriver = { int xenRegister(void) { -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif return virRegisterDriver(&xenUnifiedDriver); } -- 1.8.0.1.240.ge8a1f5a

On Mon, Feb 4, 2013 at 8:20 PM, Hu Tao <hutao@cn.fujitsu.com> wrote:
Don't check WITH_LIBVIRTD in C source files because we will build the sources even without libvirtd. --- src/driver.h | 4 ---- src/libvirt.c | 7 ------- src/libvirt_internal.h | 2 -- src/remote/remote_driver.c | 6 ------ src/xen/xen_driver.c | 6 +----- 5 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..e2a7b5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -118,10 +118,8 @@ static virSecretDriverPtr virSecretDriverTab[MAX_DRIVERS]; static int virSecretDriverTabCount = 0; static virNWFilterDriverPtr virNWFilterDriverTab[MAX_DRIVERS]; static int virNWFilterDriverTabCount = 0; -#ifdef WITH_LIBVIRTD static virStateDriverPtr virStateDriverTab[MAX_DRIVERS]; static int virStateDriverTabCount = 0; -#endif
#if defined(POLKIT_AUTH) @@ -771,7 +769,6 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; }
-#ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: * @driver: pointer to a driver block @@ -885,10 +882,6 @@ int virStateStop(void) { return ret; }
-#endif - - - /** * virGetVersion: * @libVer: return value for the library version (OUT) diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 595d2db..b82f6b9 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,7 +27,6 @@
# include "internal.h"
-# ifdef WITH_LIBVIRTD typedef void (*virStateInhibitCallback)(bool inhibit, void *opaque);
@@ -37,7 +36,6 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); -# endif
/* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 341321b..354a216 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -156,7 +156,6 @@ static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr /* Helper functions for remoteOpen. */ static char *get_transport_from_scheme(char *scheme);
-#ifdef WITH_LIBVIRTD static int remoteStartup(bool privileged ATTRIBUTE_UNUSED, virStateInhibitCallback callback ATTRIBUTE_UNUSED, @@ -168,7 +167,6 @@ remoteStartup(bool privileged ATTRIBUTE_UNUSED, inside_daemon = true; return 0; } -#endif
#ifndef WIN32 /** @@ -6382,12 +6380,10 @@ static virNWFilterDriver nwfilter_driver = { };
-#ifdef WITH_LIBVIRTD static virStateDriver state_driver = { .name = "Remote", .initialize = remoteStartup, }; -#endif
/** remoteRegister: @@ -6408,9 +6404,7 @@ remoteRegister(void) if (virRegisterDeviceMonitor(&dev_monitor) == -1) return -1; if (virRegisterSecretDriver(&secret_driver) == -1) return -1; if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1; -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return 0; } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 2795ebc..d65f4a6 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -91,7 +91,7 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif };
-#if defined WITH_LIBVIRTD || defined __sun +#ifdef __sun static bool inside_daemon = false; #endif
@@ -200,7 +200,6 @@ done: return res; }
-#ifdef WITH_LIBVIRTD
static int xenInitialize(bool privileged ATTRIBUTE_UNUSED, @@ -216,7 +215,6 @@ static virStateDriver state_driver = { .initialize = xenInitialize, };
-#endif
/*----- Dispatch functions. -----*/
@@ -2398,9 +2396,7 @@ static virDriver xenUnifiedDriver = { int xenRegister(void) { -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return virRegisterDriver(&xenUnifiedDriver); } -- 1.8.0.1.240.ge8a1f5a
What platform or target were you aiming this for that this was needed? This appears to prevent supporting backends from being registered while the other parts of the code provide other functionality. -- Doug Goldstein

On Mon, Feb 04, 2013 at 10:08:42PM -0600, Doug Goldstein wrote:
On Mon, Feb 4, 2013 at 8:20 PM, Hu Tao <hutao@cn.fujitsu.com> wrote:
Don't check WITH_LIBVIRTD in C source files because we will build the sources even without libvirtd. --- src/driver.h | 4 ---- src/libvirt.c | 7 ------- src/libvirt_internal.h | 2 -- src/remote/remote_driver.c | 6 ------ src/xen/xen_driver.c | 6 +----- 5 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..e2a7b5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -118,10 +118,8 @@ static virSecretDriverPtr virSecretDriverTab[MAX_DRIVERS]; static int virSecretDriverTabCount = 0; static virNWFilterDriverPtr virNWFilterDriverTab[MAX_DRIVERS]; static int virNWFilterDriverTabCount = 0; -#ifdef WITH_LIBVIRTD static virStateDriverPtr virStateDriverTab[MAX_DRIVERS]; static int virStateDriverTabCount = 0; -#endif
#if defined(POLKIT_AUTH) @@ -771,7 +769,6 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; }
-#ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: * @driver: pointer to a driver block @@ -885,10 +882,6 @@ int virStateStop(void) { return ret; }
-#endif - - - /** * virGetVersion: * @libVer: return value for the library version (OUT) diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 595d2db..b82f6b9 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,7 +27,6 @@
# include "internal.h"
-# ifdef WITH_LIBVIRTD typedef void (*virStateInhibitCallback)(bool inhibit, void *opaque);
@@ -37,7 +36,6 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); -# endif
/* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 341321b..354a216 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -156,7 +156,6 @@ static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr /* Helper functions for remoteOpen. */ static char *get_transport_from_scheme(char *scheme);
-#ifdef WITH_LIBVIRTD static int remoteStartup(bool privileged ATTRIBUTE_UNUSED, virStateInhibitCallback callback ATTRIBUTE_UNUSED, @@ -168,7 +167,6 @@ remoteStartup(bool privileged ATTRIBUTE_UNUSED, inside_daemon = true; return 0; } -#endif
#ifndef WIN32 /** @@ -6382,12 +6380,10 @@ static virNWFilterDriver nwfilter_driver = { };
-#ifdef WITH_LIBVIRTD static virStateDriver state_driver = { .name = "Remote", .initialize = remoteStartup, }; -#endif
/** remoteRegister: @@ -6408,9 +6404,7 @@ remoteRegister(void) if (virRegisterDeviceMonitor(&dev_monitor) == -1) return -1; if (virRegisterSecretDriver(&secret_driver) == -1) return -1; if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1; -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return 0; } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 2795ebc..d65f4a6 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -91,7 +91,7 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif };
-#if defined WITH_LIBVIRTD || defined __sun +#ifdef __sun static bool inside_daemon = false; #endif
@@ -200,7 +200,6 @@ done: return res; }
-#ifdef WITH_LIBVIRTD
static int xenInitialize(bool privileged ATTRIBUTE_UNUSED, @@ -216,7 +215,6 @@ static virStateDriver state_driver = { .initialize = xenInitialize, };
-#endif
/*----- Dispatch functions. -----*/
@@ -2398,9 +2396,7 @@ static virDriver xenUnifiedDriver = { int xenRegister(void) { -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return virRegisterDriver(&xenUnifiedDriver); } -- 1.8.0.1.240.ge8a1f5a
What platform or target were you aiming this for that this was needed? This appears to prevent supporting backends from being registered while the other parts of the code provide other functionality.
I didn't mention the patch is to solve the build failure with --without-libvirtd. In the first version[1] I provided stubs for those functions defined with WITH_LIBVIRTD, but DanP suggested to remove all WITH_LIBVIRTD in files in src/, if I understood correctly. [1] https://www.redhat.com/archives/libvir-list/2013-February/msg00087.html -- Regards, Hu Tao

On Mon, Feb 04, 2013 at 10:08:42PM -0600, Doug Goldstein wrote:
On Mon, Feb 4, 2013 at 8:20 PM, Hu Tao <hutao@cn.fujitsu.com> wrote:
Don't check WITH_LIBVIRTD in C source files because we will build the sources even without libvirtd. --- src/driver.h | 4 ---- src/libvirt.c | 7 ------- src/libvirt_internal.h | 2 -- src/remote/remote_driver.c | 6 ------ src/xen/xen_driver.c | 6 +----- 5 files changed, 1 insertion(+), 24 deletions(-)
@@ -216,7 +215,6 @@ static virStateDriver state_driver = { .initialize = xenInitialize, };
-#endif
/*----- Dispatch functions. -----*/
@@ -2398,9 +2396,7 @@ static virDriver xenUnifiedDriver = { int xenRegister(void) { -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return virRegisterDriver(&xenUnifiedDriver); } -- 1.8.0.1.240.ge8a1f5a
What platform or target were you aiming this for that this was needed? This appears to prevent supporting backends from being registered while the other parts of the code provide other functionality.
I'm not sure I understand what your concern is here. If we build with --without-libvirtd, then the 'xen' driver is forcably disabled. So this change should effectively be a no-op in this area. 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 :|

Please add one more line to commit msg: On Tue, Feb 05, 2013 at 10:20:37AM +0800, Hu Tao wrote:
Don't check WITH_LIBVIRTD in C source files because we will build the sources even without libvirtd.
This patch also fix the build failure when buliding with --without-libvirtd.
--- src/driver.h | 4 ---- src/libvirt.c | 7 ------- src/libvirt_internal.h | 2 -- src/remote/remote_driver.c | 6 ------ src/xen/xen_driver.c | 6 +----- 5 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/src/driver.h b/src/driver.h index 02ddd83..dab7495 100644 --- a/src/driver.h +++ b/src/driver.h @@ -1512,7 +1512,6 @@ struct _virStorageDriver { virDrvStoragePoolIsPersistent poolIsPersistent; };
-# ifdef WITH_LIBVIRTD
typedef int (*virDrvStateInitialize) (bool privileged, virStateInhibitCallback callback, @@ -1531,7 +1530,6 @@ struct _virStateDriver { virDrvStateReload reload; virDrvStateStop stop; }; -# endif
typedef struct _virDeviceMonitor virDeviceMonitor; @@ -1768,9 +1766,7 @@ int virRegisterStorageDriver(virStorageDriverPtr); int virRegisterDeviceMonitor(virDeviceMonitorPtr); int virRegisterSecretDriver(virSecretDriverPtr); int virRegisterNWFilterDriver(virNWFilterDriverPtr); -# ifdef WITH_LIBVIRTD int virRegisterStateDriver(virStateDriverPtr); -# endif void virDriverModuleInitialize(const char *defmoddir); void *virDriverLoadModule(const char *name);
diff --git a/src/libvirt.c b/src/libvirt.c index f81a3de..e2a7b5d 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -118,10 +118,8 @@ static virSecretDriverPtr virSecretDriverTab[MAX_DRIVERS]; static int virSecretDriverTabCount = 0; static virNWFilterDriverPtr virNWFilterDriverTab[MAX_DRIVERS]; static int virNWFilterDriverTabCount = 0; -#ifdef WITH_LIBVIRTD static virStateDriverPtr virStateDriverTab[MAX_DRIVERS]; static int virStateDriverTabCount = 0; -#endif
#if defined(POLKIT_AUTH) @@ -771,7 +769,6 @@ virRegisterDriver(virDriverPtr driver) return virDriverTabCount++; }
-#ifdef WITH_LIBVIRTD /** * virRegisterStateDriver: * @driver: pointer to a driver block @@ -885,10 +882,6 @@ int virStateStop(void) { return ret; }
-#endif - - - /** * virGetVersion: * @libVer: return value for the library version (OUT) diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 595d2db..b82f6b9 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -27,7 +27,6 @@
# include "internal.h"
-# ifdef WITH_LIBVIRTD typedef void (*virStateInhibitCallback)(bool inhibit, void *opaque);
@@ -37,7 +36,6 @@ int virStateInitialize(bool privileged, int virStateCleanup(void); int virStateReload(void); int virStateStop(void); -# endif
/* Feature detection. This is a libvirt-private interface for determining * what features are supported by the driver. diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 341321b..354a216 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -156,7 +156,6 @@ static void remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr /* Helper functions for remoteOpen. */ static char *get_transport_from_scheme(char *scheme);
-#ifdef WITH_LIBVIRTD static int remoteStartup(bool privileged ATTRIBUTE_UNUSED, virStateInhibitCallback callback ATTRIBUTE_UNUSED, @@ -168,7 +167,6 @@ remoteStartup(bool privileged ATTRIBUTE_UNUSED, inside_daemon = true; return 0; } -#endif
#ifndef WIN32 /** @@ -6382,12 +6380,10 @@ static virNWFilterDriver nwfilter_driver = { };
-#ifdef WITH_LIBVIRTD static virStateDriver state_driver = { .name = "Remote", .initialize = remoteStartup, }; -#endif
/** remoteRegister: @@ -6408,9 +6404,7 @@ remoteRegister(void) if (virRegisterDeviceMonitor(&dev_monitor) == -1) return -1; if (virRegisterSecretDriver(&secret_driver) == -1) return -1; if (virRegisterNWFilterDriver(&nwfilter_driver) == -1) return -1; -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return 0; } diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 2795ebc..d65f4a6 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -91,7 +91,7 @@ static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = { #endif };
-#if defined WITH_LIBVIRTD || defined __sun +#ifdef __sun static bool inside_daemon = false; #endif
@@ -200,7 +200,6 @@ done: return res; }
-#ifdef WITH_LIBVIRTD
static int xenInitialize(bool privileged ATTRIBUTE_UNUSED, @@ -216,7 +215,6 @@ static virStateDriver state_driver = { .initialize = xenInitialize, };
-#endif
/*----- Dispatch functions. -----*/
@@ -2398,9 +2396,7 @@ static virDriver xenUnifiedDriver = { int xenRegister(void) { -#ifdef WITH_LIBVIRTD if (virRegisterStateDriver(&state_driver) == -1) return -1; -#endif
return virRegisterDriver(&xenUnifiedDriver); } -- 1.8.0.1.240.ge8a1f5a
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (4)
-
Daniel P. Berrange
-
Doug Goldstein
-
Hu Tao
-
Martin Kletzander