]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
kvm tools: Introduce --guest-ip option
authorAsias He <asias.hejun@gmail.com>
Sun, 17 Jul 2011 08:57:00 +0000 (16:57 +0800)
committerPekka Enberg <penberg@kernel.org>
Mon, 18 Jul 2011 10:17:17 +0000 (13:17 +0300)
The --guest-ip option tells which IP address to give guest through DHCP.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
tools/kvm/builtin-run.c
tools/kvm/include/kvm/virtio-net.h

index 8b7d08b0105c8d235e023b4e388c9269501b9f24..01a1de27b45bf7d550615b1912cfe3f83877dd9a 100644 (file)
@@ -45,6 +45,7 @@
 #define DEFAULT_CONSOLE                "serial"
 #define DEFAULT_NETWORK                "user"
 #define DEFAULT_HOST_ADDR      "192.168.33.1"
+#define DEFAULT_GUEST_ADDR     "192.168.33.15"
 #define DEFAULT_GUEST_MAC      "00:15:15:15:15:15"
 #define DEFAULT_SCRIPT         "none"
 
@@ -68,6 +69,7 @@ static const char *console;
 static const char *kvm_dev;
 static const char *network;
 static const char *host_ip_addr;
+static const char *guest_ip;
 static const char *guest_mac;
 static const char *script;
 static const char *guest_name;
@@ -164,6 +166,8 @@ static const struct option options[] = {
                        "Network to use"),
        OPT_STRING('\0', "host-ip-addr", &host_ip_addr, "a.b.c.d",
                        "Assign this address to the host side networking"),
+       OPT_STRING('\0', "guest-ip", &guest_ip, "a.b.c.d",
+                       "Assign this address to the guest side networking"),
        OPT_STRING('\0', "guest-mac", &guest_mac, "aa:bb:cc:dd:ee:ff",
                        "Assign this address to the guest side NIC"),
        OPT_STRING('\0', "tapscript", &script, "Script path",
@@ -542,6 +546,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
        if (!host_ip_addr)
                host_ip_addr = DEFAULT_HOST_ADDR;
 
+       if (!guest_ip)
+               guest_ip = DEFAULT_GUEST_ADDR;
+
        if (!guest_mac)
                guest_mac = DEFAULT_GUEST_MAC;
 
@@ -647,6 +654,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 
        if (strncmp(network, "none", 4)) {
                net_params.host_ip = host_ip_addr;
+               net_params.guest_ip = guest_ip;
                net_params.kvm = kvm;
                net_params.script = script;
                sscanf(guest_mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
index e93e8e4cac8c8d6f9e1e69d65238718be7481091..9ff0e153f8e9d2e06edcb5bb06a518288a0b68a1 100644 (file)
@@ -4,10 +4,11 @@
 struct kvm;
 
 struct virtio_net_parameters {
-       struct kvm *kvm;
+       const char *guest_ip;
        const char *host_ip;
-       char guest_mac[6];
        const char *script;
+       char guest_mac[6];
+       struct kvm *kvm;
        int mode;
 };