File dhcp-fix.patch of Package virt-sandbox
Patch aggegrating the following upstream commits:
82cc162 Create /dev/fd symlink to /proc/self/fd
5fe7883 Only show dhclient output in debug mode.
daa2665 Add af_packet module for dhclient to work
Index: libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-builder-machine.c
===================================================================
--- libvirt-sandbox-0.6.0.orig/libvirt-sandbox/libvirt-sandbox-builder-machine.c
+++ libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-builder-machine.c
@@ -182,6 +182,11 @@ static gchar *gvir_sandbox_builder_machi
gvir_sandbox_config_initrd_add_module(initrd, "virtio_balloon.ko");
#endif
+ /* For dhclient to work in user networking setup
+ * Some distros like fedora have it builtin, we need not to fail if
+ * the file isn't found */
+ gvir_sandbox_config_initrd_add_module(initrd, "af_packet.ko");
+
if (!gvir_sandbox_builder_initrd_construct(builder, initrd, targetfile, error))
goto cleanup;
Index: libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-init-qemu.c
===================================================================
--- libvirt-sandbox-0.6.0.orig/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -356,6 +356,12 @@ main(int argc ATTR_UNUSED, char **argv A
/* Main special filesystems */
mount_other("/dev", "devtmpfs", 0755);
+ if (symlink("/proc/self/fd", "/dev/fd") < 0) {
+ fprintf(stderr, "libvirt-sandbox-init-qemu: %s: failed to create /dev/fd symlink: %s\n",
+ __func__, strerror(errno));
+ exit_poweroff();
+ }
+
mount_other_opts("/dev/pts", "devpts", "gid=5,mode=620,ptmxmode=000", 0755);
mount_other("/sys", "sysfs", 0755);
mount_other("/proc", "proc", 0755);
Index: libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-init-common.c
===================================================================
--- libvirt-sandbox-0.6.0.orig/libvirt-sandbox/libvirt-sandbox-init-common.c
+++ libvirt-sandbox-0.6.0/libvirt-sandbox/libvirt-sandbox-init-common.c
@@ -159,11 +159,19 @@ start_shell(void)
static gboolean start_dhcp(const gchar *devname, GError **error)
{
- const gchar *argv[] = { "/sbin/dhclient", "-v", "--no-pid", devname, NULL };
+ const gchar *argv[5];
+ size_t nargs = 0;
gboolean ret;
sigset_t newset;
sigset_t oldset;
+ argv[nargs++] = "/sbin/dhclient";
+ if (debug)
+ argv[nargs++] = "-v";
+ argv[nargs++] = "--no-pid";
+ argv[nargs++] = devname;
+ argv[nargs++] = NULL;
+
sigemptyset(&newset);
sigaddset(&newset, SIGHUP);