On 3/11/06, Paul Brook <[EMAIL PROTECTED]> wrote:
> This should be set via -net user,hostname=foo. No need for a separate option.

I agree, since the hostname is relevant only for user-net interfaces.
An updated patch is attached.

The only issue is that there's just a single, global hostname, not a
hostname per user-net interface. On the other hand, I'm not sure if
qemu supports multiple user-net interfaces in the first place. Does
the following configuration make sense?

    -net nic,vlan=0 -net user,vlan=0 -net nic,vlan=1 -net user,vlan=1

--Ed
diff -BurN qemu-snapshot-2006-03-06_23.orig/slirp/bootp.c qemu-snapshot-2006-03-06_23/slirp/bootp.c
--- qemu-snapshot-2006-03-06_23.orig/slirp/bootp.c	2005-06-05 17:11:42.000000000 +0000
+++ qemu-snapshot-2006-03-06_23/slirp/bootp.c	2006-03-10 07:11:19.000000000 +0000
@@ -228,6 +228,16 @@
         val = htonl(LEASE_TIME);
         memcpy(q, &val, 4);
         q += 4;
+
+        if (slirp_hostname && *slirp_hostname) {
+            val = strlen(slirp_hostname);
+            if (val > 32)
+                val = 32;
+            *q++ = RFC1533_HOSTNAME;
+            *q++ = val;
+            memcpy(q, slirp_hostname, val);
+            q += val;
+        }
     }
     *q++ = RFC1533_END;
     
diff -BurN qemu-snapshot-2006-03-06_23.orig/slirp/libslirp.h qemu-snapshot-2006-03-06_23/slirp/libslirp.h
--- qemu-snapshot-2006-03-06_23.orig/slirp/libslirp.h	2005-06-05 17:11:42.000000000 +0000
+++ qemu-snapshot-2006-03-06_23/slirp/libslirp.h	2006-03-10 06:47:32.000000000 +0000
@@ -32,6 +32,7 @@
                    int guest_port);
 
 extern const char *tftp_prefix;
+extern const char *slirp_hostname;
 
 #ifdef __cplusplus
 }
diff -BurN qemu-snapshot-2006-03-06_23.orig/slirp/slirp.c qemu-snapshot-2006-03-06_23/slirp/slirp.c
--- qemu-snapshot-2006-03-06_23.orig/slirp/slirp.c	2005-09-03 10:45:09.000000000 +0000
+++ qemu-snapshot-2006-03-06_23/slirp/slirp.c	2006-03-10 06:46:28.000000000 +0000
@@ -25,6 +25,8 @@
 /* XXX: suppress those select globals */
 fd_set *global_readfds, *global_writefds, *global_xfds;
 
+const char *slirp_hostname = NULL;
+
 #ifdef _WIN32
 
 static int get_dns_addr(struct in_addr *pdns_addr)
diff -BurN qemu-snapshot-2006-03-06_23.orig/vl.c qemu-snapshot-2006-03-06_23/vl.c
--- qemu-snapshot-2006-03-06_23.orig/vl.c	2006-02-20 00:33:36.000000000 +0000
+++ qemu-snapshot-2006-03-06_23/vl.c	2006-03-13 01:35:45.000000000 +0000
@@ -2758,6 +2758,12 @@
     } else
 #ifdef CONFIG_SLIRP
     if (!strcmp(device, "user")) {
+        if (get_param_value(buf, sizeof(buf), "hostname", p)) {
+            if (slirp_hostname)
+                fprintf(stderr, "hostname already set; ignoring hostname=%s\n", buf);
+            else
+                slirp_hostname = strdup(buf);
+        }
         ret = net_slirp_init(vlan);
     } else
 #endif
@@ -4157,8 +4163,9 @@
            "-net nic[,vlan=n][,macaddr=addr][,model=type]\n"
            "                create a new Network Interface Card and connect it to VLAN 'n'\n"
 #ifdef CONFIG_SLIRP
-           "-net user[,vlan=n]\n"
-           "                connect the user mode network stack to VLAN 'n'\n"
+           "-net user[,vlan=n][,hostname=host]\n"
+           "                connect the user mode network stack to VLAN 'n' and send\n"
+           "                hostname 'host' to DHCP clients\n"
 #endif
 #ifdef _WIN32
            "-net tap[,vlan=n],ifname=name\n"
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to