[libvirt] [PATCH 0/2] bugfix: support dhcp network interfaces

Support for a network such as -N dhcp,source=default was not working in that dhclient was not being started. Although I am not sure what the real problem is, the solution is to use g_spawn_sync() instead of g_spawn_async() to start /sbin/dhclient. The second patch addes "-v" to the dhclient arguments to improve debugging info. The dhclient into will be in /var/log/messages the Secure Contrainer host system and not in the container itself. Gene Czarcinski (2): for dhclient use g_spawn_sync instead of g_spawn_async add -v to dhclient parameter arguments libvirt-sandbox/libvirt-sandbox-init-common.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) -- 1.9.3

For some (unknown) reason, g_spawn_async() is not starting dhclient so that a dhcp NIC can be configured. However, simply using g_spawn_sync() works. This was the only use of g_spawn_async(). Note: There is no problem using sync instead of async since dhclient will disconnect and put itself in the background once the network is started. --- libvirt-sandbox/libvirt-sandbox-init-common.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libvirt-sandbox/libvirt-sandbox-init-common.c b/libvirt-sandbox/libvirt-sandbox-init-common.c index e5f8af0..49baa5c 100644 --- a/libvirt-sandbox/libvirt-sandbox-init-common.c +++ b/libvirt-sandbox/libvirt-sandbox-init-common.c @@ -113,10 +113,8 @@ static gboolean start_dhcp(const gchar *devname, GError **error) { const gchar *argv[] = { "/sbin/dhclient", "--no-pid", devname, NULL }; - if (!g_spawn_async(NULL, (gchar**)argv, NULL, - G_SPAWN_STDOUT_TO_DEV_NULL | - G_SPAWN_STDERR_TO_DEV_NULL, - NULL, NULL, NULL, error)) + if (!g_spawn_sync(NULL, (gchar**)argv, NULL, 0, + NULL, NULL, NULL, NULL, NULL, error)) return FALSE; return TRUE; -- 1.9.3

This improves the ablityh to diagnose problems. --- libvirt-sandbox/libvirt-sandbox-init-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libvirt-sandbox/libvirt-sandbox-init-common.c b/libvirt-sandbox/libvirt-sandbox-init-common.c index 49baa5c..056cbc2 100644 --- a/libvirt-sandbox/libvirt-sandbox-init-common.c +++ b/libvirt-sandbox/libvirt-sandbox-init-common.c @@ -111,7 +111,7 @@ start_shell(void) static gboolean start_dhcp(const gchar *devname, GError **error) { - const gchar *argv[] = { "/sbin/dhclient", "--no-pid", devname, NULL }; + const gchar *argv[] = { "/sbin/dhclient", "-v", "--no-pid", devname, NULL }; if (!g_spawn_sync(NULL, (gchar**)argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, error)) -- 1.9.3

On 09/09/2014 12:50 PM, Gene Czarcinski wrote:
Support for a network such as -N dhcp,source=default was not working in that dhclient was not being started. Although I am not sure what the real problem is, the solution is to use g_spawn_sync() instead of g_spawn_async() to start /sbin/dhclient.
The second patch addes "-v" to the dhclient arguments to improve debugging info. The dhclient into will be in /var/log/messages the Secure Contrainer host system and not in the container itself.
Gene Czarcinski (2): for dhclient use g_spawn_sync instead of g_spawn_async add -v to dhclient parameter arguments
libvirt-sandbox/libvirt-sandbox-init-common.c | 8 +++-----
Given the file you are patching, it might help to do: git config format.subjectprefix 'sandbox PATCH' so that it is obvious this is a different repo than the normal libvirt.git. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Gene Czarcinski