mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-05 13:11:44 +00:00
kvm tools: Introduce --host-mac option
The --host-mac option sets up MAC address of host. Signed-off-by: Asias He <asias.hejun@gmail.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#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_HOST_MAC "00:01:01:01:01:01"
|
||||
#define DEFAULT_SCRIPT "none"
|
||||
|
||||
#define MB_SHIFT (20)
|
||||
@@ -71,6 +72,7 @@ static const char *network;
|
||||
static const char *host_ip_addr;
|
||||
static const char *guest_ip;
|
||||
static const char *guest_mac;
|
||||
static const char *host_mac;
|
||||
static const char *script;
|
||||
static const char *guest_name;
|
||||
static bool single_step;
|
||||
@@ -168,6 +170,8 @@ static const struct option options[] = {
|
||||
"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', "host-mac", &host_mac, "aa:bb:cc:dd:ee:ff",
|
||||
"Assign this address to the host side NIC"),
|
||||
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",
|
||||
@@ -552,6 +556,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
|
||||
if (!guest_mac)
|
||||
guest_mac = DEFAULT_GUEST_MAC;
|
||||
|
||||
if (!host_mac)
|
||||
host_mac = DEFAULT_HOST_MAC;
|
||||
|
||||
if (!script)
|
||||
script = DEFAULT_SCRIPT;
|
||||
|
||||
@@ -664,6 +671,13 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
|
||||
net_params.guest_mac+3,
|
||||
net_params.guest_mac+4,
|
||||
net_params.guest_mac+5);
|
||||
sscanf(host_mac, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
|
||||
net_params.host_mac,
|
||||
net_params.host_mac+1,
|
||||
net_params.host_mac+2,
|
||||
net_params.host_mac+3,
|
||||
net_params.host_mac+4,
|
||||
net_params.host_mac+5);
|
||||
|
||||
if (!strncmp(network, "user", 4))
|
||||
net_params.mode = NET_MODE_USER;
|
||||
|
||||
@@ -8,6 +8,7 @@ struct virtio_net_parameters {
|
||||
const char *host_ip;
|
||||
const char *script;
|
||||
char guest_mac[6];
|
||||
char host_mac[6];
|
||||
struct kvm *kvm;
|
||||
int mode;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user