qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Ed Swierk" <eswierk@gmail.com>
To: qemu-devel@nongnu.org
Cc: paul@codesourcery.com
Subject: Re: [Qemu-devel] [PATCH] Set hostname in DHCP response
Date: Sun, 12 Mar 2006 18:13:48 -0800	[thread overview]
Message-ID: <c1bf1cf0603121813n534b91bej5861d04972a9cf89@mail.gmail.com> (raw)
In-Reply-To: <200603112219.27328.paul@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 558 bytes --]

On 3/11/06, Paul Brook <paul@codesourcery.com> 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

[-- Attachment #2: qemu-hostname.patch --]
[-- Type: text/x-patch, Size: 2857 bytes --]

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"

  reply	other threads:[~2006-03-13  2:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-10  7:35 [Qemu-devel] [PATCH] Set hostname in DHCP response Ed Swierk
2006-03-11 22:19 ` Paul Brook
2006-03-13  2:13   ` Ed Swierk [this message]
2006-03-13  2:46     ` Leonardo E. Reiter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c1bf1cf0603121813n534b91bej5861d04972a9cf89@mail.gmail.com \
    --to=eswierk@gmail.com \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).