From patchwork Sun Jul 17 08:57:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 983002 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6H8xh1H023917 for ; Sun, 17 Jul 2011 08:59:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754246Ab1GQI7k (ORCPT ); Sun, 17 Jul 2011 04:59:40 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:39735 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754231Ab1GQI7k (ORCPT ); Sun, 17 Jul 2011 04:59:40 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so2303241iyb.19 for ; Sun, 17 Jul 2011 01:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=Lq1TUEPIEuriGCCzSrpe98twn2USTiwk1/95DNuNxvo=; b=sJExIwIrdtt7FjpZzaIdIZfc8HZwYsS8L/u///ivyK2VoJMOtr5iw7LODEWz+fPCeT mBE39BgWlk6P5YhQQLC9qKImfDblc52w5ix8Sw53l55G8rd8/VLm+yzoHCTry8i5zUDz yF02ilf2xERZtMzRR1qITNs14O8V/kWETUi+s= Received: by 10.42.75.194 with SMTP id b2mr5332173ick.286.1310893179691; Sun, 17 Jul 2011 01:59:39 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id us2sm3593680icb.19.2011.07.17.01.59.36 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jul 2011 01:59:39 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH 12/16] kvm tools: Introduce --guest-ip option Date: Sun, 17 Jul 2011 16:57:00 +0800 Message-Id: <1310893024-21615-13-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> References: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 17 Jul 2011 08:59:43 +0000 (UTC) The --guest-ip option tells which IP address to give guest through DHCP. Signed-off-by: Asias He --- tools/kvm/builtin-run.c | 8 ++++++++ tools/kvm/include/kvm/virtio-net.h | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c index 8b7d08b..01a1de2 100644 --- a/tools/kvm/builtin-run.c +++ b/tools/kvm/builtin-run.c @@ -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", diff --git a/tools/kvm/include/kvm/virtio-net.h b/tools/kvm/include/kvm/virtio-net.h index e93e8e4..9ff0e15 100644 --- a/tools/kvm/include/kvm/virtio-net.h +++ b/tools/kvm/include/kvm/virtio-net.h @@ -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; };