public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] kvm tools: Set up tun interface using ioctls
@ 2011-04-13 12:13 Sasha Levin
  2011-04-13 12:13 ` [PATCH 2/2] kvm tools: Make host side IP configurable Sasha Levin
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sasha Levin @ 2011-04-13 12:13 UTC (permalink / raw)
  To: penberg, gorcunov, asias.hejun; +Cc: kvm, Sasha Levin

Use ioctls to assign IP address and bring interface up instead of using ifconfig.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/virtio-net.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/tools/kvm/virtio-net.c b/tools/kvm/virtio-net.c
index ec70d5c..5f9bf07 100644
--- a/tools/kvm/virtio-net.c
+++ b/tools/kvm/virtio-net.c
@@ -14,6 +14,9 @@
 #include <sys/ioctl.h>
 #include <assert.h>
 #include <fcntl.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 
 #define VIRTIO_NET_IRQ		14
 #define VIRTIO_NET_QUEUE_SIZE	128
@@ -276,7 +279,7 @@ static struct pci_device_header virtio_net_pci_device = {
 static void virtio_net__tap_init(void)
 {
 	struct ifreq ifr;
-
+	int sock = socket(AF_INET, SOCK_STREAM, 0);
 	net_device.tap_fd = open("/dev/net/tun", O_RDWR);
 	if (net_device.tap_fd < 0)
 		die("Unable to open /dev/net/tun\n");
@@ -291,9 +294,25 @@ static void virtio_net__tap_init(void)
 
 	ioctl(net_device.tap_fd, TUNSETNOCSUM, 1);
 
+	memset(&ifr, 0, sizeof(ifr));
+
+	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
+
 	/*FIXME: Remove this after user can specify ip address and netmask*/
-	if (system("ifconfig tap0 192.168.33.2") < 0)
-		warning("Can not set ip address on tap0");
+	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr("192.168.33.2");
+	ifr.ifr_addr.sa_family = AF_INET;
+
+	if (ioctl(sock, SIOCSIFADDR, &ifr) < 0)
+		warning("Can not set ip address on tap device");
+
+	memset(&ifr, 0, sizeof(ifr));
+	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
+	ioctl(sock, SIOCGIFFLAGS, &ifr);
+	ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
+	if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0)
+		warning("Could not bring tap device up");
+
+	close(sock);
 }
 
 static void virtio_net__io_thread_init(struct kvm *self)
-- 
1.7.5.rc1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 12:13 [PATCH 1/2] kvm tools: Set up tun interface using ioctls Sasha Levin
@ 2011-04-13 12:13 ` Sasha Levin
  2011-04-13 12:28   ` Asias He
  2011-04-13 12:39 ` [PATCH 1/2] kvm tools: Set up tun interface using ioctls Asias He
  2011-04-13 13:49 ` Pekka Enberg
  2 siblings, 1 reply; 12+ messages in thread
From: Sasha Levin @ 2011-04-13 12:13 UTC (permalink / raw)
  To: penberg, gorcunov, asias.hejun; +Cc: kvm, Sasha Levin

Add --host-ip-addr parameter to allow changing the host-side IP address.

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 tools/kvm/include/kvm/virtio-net.h |    2 +-
 tools/kvm/kvm-run.c                |    9 ++++++++-
 tools/kvm/virtio-net.c             |    9 ++++-----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/kvm/include/kvm/virtio-net.h b/tools/kvm/include/kvm/virtio-net.h
index a1cab15..03eb623 100644
--- a/tools/kvm/include/kvm/virtio-net.h
+++ b/tools/kvm/include/kvm/virtio-net.h
@@ -2,6 +2,6 @@
 #define KVM__VIRTIO_NET_H
 
 struct kvm;
-void virtio_net__init(struct kvm *self);
+void virtio_net__init(struct kvm *self, const char* host_ip_addr);
 
 #endif /* KVM__VIRTIO_NET_H */
diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
index 6046a0a..910a8d8 100644
--- a/tools/kvm/kvm-run.c
+++ b/tools/kvm/kvm-run.c
@@ -31,6 +31,7 @@
 #define DEFAULT_KVM_DEV		"/dev/kvm"
 #define DEFAULT_CONSOLE		"serial"
 #define DEFAULT_NETWORK		"none"
+#define DEFAULT_HOST_ADDR	"192.168.33.2"
 
 #define MB_SHIFT		(20)
 #define MIN_RAM_SIZE_MB		(64ULL)
@@ -66,6 +67,7 @@ static const char *image_filename;
 static const char *console;
 static const char *kvm_dev;
 static const char *network;
+static const char *host_ip_addr;
 static bool single_step;
 static bool readonly_image;
 extern bool ioport_debug;
@@ -89,6 +91,8 @@ static const struct option options[] = {
 			"Console to use"),
 	OPT_STRING('n', "network", &network, "virtio",
 			"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_GROUP("Kernel options:"),
 	OPT_STRING('k', "kernel", &kernel_filename, "kernel",
@@ -218,6 +222,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 	else
 		active_console  = CONSOLE_8250;
 
+	if (!host_ip_addr)
+		host_ip_addr = DEFAULT_HOST_ADDR;
+
 	term_init();
 
 	kvm = kvm__init(kvm_dev, ram_size);
@@ -259,7 +266,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
 		network = DEFAULT_NETWORK;
 
 	if (!strncmp(network, "virtio", 6))
-		virtio_net__init(kvm);
+		virtio_net__init(kvm, host_ip_addr);
 
 	kvm__start_timer(kvm);
 
diff --git a/tools/kvm/virtio-net.c b/tools/kvm/virtio-net.c
index 5f9bf07..ec65779 100644
--- a/tools/kvm/virtio-net.c
+++ b/tools/kvm/virtio-net.c
@@ -276,7 +276,7 @@ static struct pci_device_header virtio_net_pci_device = {
 	.irq_line		= VIRTIO_NET_IRQ,
 };
 
-static void virtio_net__tap_init(void)
+static void virtio_net__tap_init(const char *host_ip_addr)
 {
 	struct ifreq ifr;
 	int sock = socket(AF_INET, SOCK_STREAM, 0);
@@ -298,8 +298,7 @@ static void virtio_net__tap_init(void)
 
 	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
 
-	/*FIXME: Remove this after user can specify ip address and netmask*/
-	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr("192.168.33.2");
+	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr(host_ip_addr);
 	ifr.ifr_addr.sa_family = AF_INET;
 
 	if (ioctl(sock, SIOCSIFADDR, &ifr) < 0)
@@ -327,11 +326,11 @@ static void virtio_net__io_thread_init(struct kvm *self)
 	pthread_create(&net_device.io_tx_thread, NULL, virtio_net_tx_thread, (void *)self);
 }
 
-void virtio_net__init(struct kvm *self)
+void virtio_net__init(struct kvm *self, const char* host_ip_addr)
 {
 	pci__register(&virtio_net_pci_device, PCI_VIRTIO_NET_DEVNUM);
 	ioport__register(IOPORT_VIRTIO_NET, &virtio_net_io_ops, IOPORT_VIRTIO_NET_SIZE);
 
-	virtio_net__tap_init();
+	virtio_net__tap_init(host_ip_addr);
 	virtio_net__io_thread_init(self);
 }
-- 
1.7.5.rc1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 12:13 ` [PATCH 2/2] kvm tools: Make host side IP configurable Sasha Levin
@ 2011-04-13 12:28   ` Asias He
  2011-04-13 12:35     ` Pekka Enberg
  2011-04-13 13:28     ` Asias He
  0 siblings, 2 replies; 12+ messages in thread
From: Asias He @ 2011-04-13 12:28 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, gorcunov, kvm

On 04/13/2011 08:13 PM, Sasha Levin wrote:
> Add --host-ip-addr parameter to allow changing the host-side IP address.


I'd personally prefer something like this:

--network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy

Once we can set up ip address for guest, we can use:

--network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v

> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
>  tools/kvm/include/kvm/virtio-net.h |    2 +-
>  tools/kvm/kvm-run.c                |    9 ++++++++-
>  tools/kvm/virtio-net.c             |    9 ++++-----
>  3 files changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/kvm/include/kvm/virtio-net.h b/tools/kvm/include/kvm/virtio-net.h
> index a1cab15..03eb623 100644
> --- a/tools/kvm/include/kvm/virtio-net.h
> +++ b/tools/kvm/include/kvm/virtio-net.h
> @@ -2,6 +2,6 @@
>  #define KVM__VIRTIO_NET_H
>  
>  struct kvm;
> -void virtio_net__init(struct kvm *self);
> +void virtio_net__init(struct kvm *self, const char* host_ip_addr);
>  
>  #endif /* KVM__VIRTIO_NET_H */
> diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c
> index 6046a0a..910a8d8 100644
> --- a/tools/kvm/kvm-run.c
> +++ b/tools/kvm/kvm-run.c
> @@ -31,6 +31,7 @@
>  #define DEFAULT_KVM_DEV		"/dev/kvm"
>  #define DEFAULT_CONSOLE		"serial"
>  #define DEFAULT_NETWORK		"none"
> +#define DEFAULT_HOST_ADDR	"192.168.33.2"
>  
>  #define MB_SHIFT		(20)
>  #define MIN_RAM_SIZE_MB		(64ULL)
> @@ -66,6 +67,7 @@ static const char *image_filename;
>  static const char *console;
>  static const char *kvm_dev;
>  static const char *network;
> +static const char *host_ip_addr;
>  static bool single_step;
>  static bool readonly_image;
>  extern bool ioport_debug;
> @@ -89,6 +91,8 @@ static const struct option options[] = {
>  			"Console to use"),
>  	OPT_STRING('n', "network", &network, "virtio",
>  			"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_GROUP("Kernel options:"),
>  	OPT_STRING('k', "kernel", &kernel_filename, "kernel",
> @@ -218,6 +222,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  	else
>  		active_console  = CONSOLE_8250;
>  
> +	if (!host_ip_addr)
> +		host_ip_addr = DEFAULT_HOST_ADDR;
> +
>  	term_init();
>  
>  	kvm = kvm__init(kvm_dev, ram_size);
> @@ -259,7 +266,7 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
>  		network = DEFAULT_NETWORK;
>  
>  	if (!strncmp(network, "virtio", 6))
> -		virtio_net__init(kvm);
> +		virtio_net__init(kvm, host_ip_addr);
>  
>  	kvm__start_timer(kvm);
>  
> diff --git a/tools/kvm/virtio-net.c b/tools/kvm/virtio-net.c
> index 5f9bf07..ec65779 100644
> --- a/tools/kvm/virtio-net.c
> +++ b/tools/kvm/virtio-net.c
> @@ -276,7 +276,7 @@ static struct pci_device_header virtio_net_pci_device = {
>  	.irq_line		= VIRTIO_NET_IRQ,
>  };
>  
> -static void virtio_net__tap_init(void)
> +static void virtio_net__tap_init(const char *host_ip_addr)
>  {
>  	struct ifreq ifr;
>  	int sock = socket(AF_INET, SOCK_STREAM, 0);
> @@ -298,8 +298,7 @@ static void virtio_net__tap_init(void)
>  
>  	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
>  
> -	/*FIXME: Remove this after user can specify ip address and netmask*/
> -	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr("192.168.33.2");
> +	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr(host_ip_addr);
>  	ifr.ifr_addr.sa_family = AF_INET;
>  
>  	if (ioctl(sock, SIOCSIFADDR, &ifr) < 0)
> @@ -327,11 +326,11 @@ static void virtio_net__io_thread_init(struct kvm *self)
>  	pthread_create(&net_device.io_tx_thread, NULL, virtio_net_tx_thread, (void *)self);
>  }
>  
> -void virtio_net__init(struct kvm *self)
> +void virtio_net__init(struct kvm *self, const char* host_ip_addr)
>  {
>  	pci__register(&virtio_net_pci_device, PCI_VIRTIO_NET_DEVNUM);
>  	ioport__register(IOPORT_VIRTIO_NET, &virtio_net_io_ops, IOPORT_VIRTIO_NET_SIZE);
>  
> -	virtio_net__tap_init();
> +	virtio_net__tap_init(host_ip_addr);
>  	virtio_net__io_thread_init(self);
>  }


-- 
Best Regards,
Asias He

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 12:28   ` Asias He
@ 2011-04-13 12:35     ` Pekka Enberg
  2011-04-13 13:28     ` Asias He
  1 sibling, 0 replies; 12+ messages in thread
From: Pekka Enberg @ 2011-04-13 12:35 UTC (permalink / raw)
  To: Asias He; +Cc: Sasha Levin, gorcunov, kvm, mingo

On 4/13/11 3:28 PM, Asias He wrote:
> On 04/13/2011 08:13 PM, Sasha Levin wrote:
>> Add --host-ip-addr parameter to allow changing the host-side IP address.
>
> I'd personally prefer something like this:
>
> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy
>
> Once we can set up ip address for guest, we can use:
>
> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v

What's the benefit over

   --network=virtio --hostip=x.x.x.x/mask --guestmac= [...]

form? Isn't Sasha's form a much better fit with the git-like front end 
(for parsing and help text)?

                 Pekka

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] kvm tools: Set up tun interface using ioctls
  2011-04-13 12:13 [PATCH 1/2] kvm tools: Set up tun interface using ioctls Sasha Levin
  2011-04-13 12:13 ` [PATCH 2/2] kvm tools: Make host side IP configurable Sasha Levin
@ 2011-04-13 12:39 ` Asias He
  2011-04-13 13:49 ` Pekka Enberg
  2 siblings, 0 replies; 12+ messages in thread
From: Asias He @ 2011-04-13 12:39 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, gorcunov, kvm

On 04/13/2011 08:13 PM, Sasha Levin wrote:
> Use ioctls to assign IP address and bring interface up instead of using ifconfig.
> 
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> ---
>  tools/kvm/virtio-net.c |   25 ++++++++++++++++++++++---
>  1 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kvm/virtio-net.c b/tools/kvm/virtio-net.c
> index ec70d5c..5f9bf07 100644
> --- a/tools/kvm/virtio-net.c
> +++ b/tools/kvm/virtio-net.c
> @@ -14,6 +14,9 @@
>  #include <sys/ioctl.h>
>  #include <assert.h>
>  #include <fcntl.h>
> +#include <arpa/inet.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
>  
>  #define VIRTIO_NET_IRQ		14
>  #define VIRTIO_NET_QUEUE_SIZE	128
> @@ -276,7 +279,7 @@ static struct pci_device_header virtio_net_pci_device = {
>  static void virtio_net__tap_init(void)
>  {
>  	struct ifreq ifr;
> -
> +	int sock = socket(AF_INET, SOCK_STREAM, 0);
>  	net_device.tap_fd = open("/dev/net/tun", O_RDWR);
>  	if (net_device.tap_fd < 0)
>  		die("Unable to open /dev/net/tun\n");
> @@ -291,9 +294,25 @@ static void virtio_net__tap_init(void)
>  
>  	ioctl(net_device.tap_fd, TUNSETNOCSUM, 1);
>  
> +	memset(&ifr, 0, sizeof(ifr));
> +
> +	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
> +
>  	/*FIXME: Remove this after user can specify ip address and netmask*/
> -	if (system("ifconfig tap0 192.168.33.2") < 0)
> -		warning("Can not set ip address on tap0");
> +	((struct sockaddr_in *)(&(ifr.ifr_addr)))->sin_addr.s_addr = inet_addr("192.168.33.2");
> +	ifr.ifr_addr.sa_family = AF_INET;
> +
> +	if (ioctl(sock, SIOCSIFADDR, &ifr) < 0)
> +		warning("Can not set ip address on tap device");
> +
> +	memset(&ifr, 0, sizeof(ifr));
> +	strncpy(ifr.ifr_name, net_device.tap_name, sizeof(net_device.tap_name));
> +	ioctl(sock, SIOCGIFFLAGS, &ifr);
> +	ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
> +	if (ioctl(sock, SIOCSIFFLAGS, &ifr) < 0)
> +		warning("Could not bring tap device up");
> +
> +	close(sock);
>  }
>  
>  static void virtio_net__io_thread_init(struct kvm *self)

Looks good to me.

Reviewed-by: Asias He <asias.hejun@gmail.com>

-- 
Best Regards,
Asias He

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 12:28   ` Asias He
  2011-04-13 12:35     ` Pekka Enberg
@ 2011-04-13 13:28     ` Asias He
  2011-04-13 13:38       ` Sasha Levin
  1 sibling, 1 reply; 12+ messages in thread
From: Asias He @ 2011-04-13 13:28 UTC (permalink / raw)
  To: Sasha Levin; +Cc: penberg, gorcunov, kvm

On 04/13/2011 08:28 PM, Asias He wrote:
> On 04/13/2011 08:13 PM, Sasha Levin wrote:
>> Add --host-ip-addr parameter to allow changing the host-side IP address.
> 
> 
> I'd personally prefer something like this:
> 
> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy
> 
> Once we can set up ip address for guest, we can use:
> 
> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v
> 


Alternatively, we can use an option group like this:

Network options:
    -n  --network       <virtio>
    -h  --hostip        <x.x.x.x/n>
    -y  --guestip       <x.x.x.x/n>
    -z  --guestmac      <xx:xx:xx:xx:xx:xx>


-- 
Best Regards,
Asias He

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 13:28     ` Asias He
@ 2011-04-13 13:38       ` Sasha Levin
  2011-04-13 14:07         ` Pekka Enberg
  0 siblings, 1 reply; 12+ messages in thread
From: Sasha Levin @ 2011-04-13 13:38 UTC (permalink / raw)
  To: Asias He; +Cc: penberg, gorcunov, kvm

On Wed, Apr 13, 2011 at 4:28 PM, Asias He <asias.hejun@gmail.com> wrote:
> On 04/13/2011 08:28 PM, Asias He wrote:
>> On 04/13/2011 08:13 PM, Sasha Levin wrote:
>>> Add --host-ip-addr parameter to allow changing the host-side IP address.
>>
>>
>> I'd personally prefer something like this:
>>
>> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy
>>
>> Once we can set up ip address for guest, we can use:
>>
>> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v
>>
>
>
> Alternatively, we can use an option group like this:
>
> Network options:
>    -n  --network       <virtio>
>    -h  --hostip        <x.x.x.x/n>
>    -y  --guestip       <x.x.x.x/n>
>    -z  --guestmac      <xx:xx:xx:xx:xx:xx>
>

I agree. We can create a networking group once we start expanding the options.


--
Sasha.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] kvm tools: Set up tun interface using ioctls
  2011-04-13 12:13 [PATCH 1/2] kvm tools: Set up tun interface using ioctls Sasha Levin
  2011-04-13 12:13 ` [PATCH 2/2] kvm tools: Make host side IP configurable Sasha Levin
  2011-04-13 12:39 ` [PATCH 1/2] kvm tools: Set up tun interface using ioctls Asias He
@ 2011-04-13 13:49 ` Pekka Enberg
  2011-04-13 13:59   ` Asias He
  2 siblings, 1 reply; 12+ messages in thread
From: Pekka Enberg @ 2011-04-13 13:49 UTC (permalink / raw)
  To: Sasha Levin; +Cc: gorcunov, asias.hejun, kvm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 608 bytes --]

On Wed, 13 Apr 2011, Sasha Levin wrote:
> Use ioctls to assign IP address and bring interface up instead of using ifconfig.
>
> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>

I'm seeing this:

penberg@tiger:~/linux/tools/kvm$ make
   GEN      include/common-cmds.h
   CC       8250-serial.o
   CC       virtio-blk.o
   CC       virtio-net.o
cc1: warnings being treated as errors
virtio-net.c: In function ‘virtio_net__init’:
virtio-net.c:302: error: dereferencing pointer ‘({anonymous})’ does break 
strict-aliasing rules
virtio-net.c:302: note: initialized from here
make: *** [virtio-net.o] Error 1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] kvm tools: Set up tun interface using ioctls
  2011-04-13 13:49 ` Pekka Enberg
@ 2011-04-13 13:59   ` Asias He
  2011-04-13 14:03     ` Pekka Enberg
  0 siblings, 1 reply; 12+ messages in thread
From: Asias He @ 2011-04-13 13:59 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Sasha Levin, gorcunov, kvm

On 04/13/2011 09:49 PM, Pekka Enberg wrote:
> On Wed, 13 Apr 2011, Sasha Levin wrote:
>> Use ioctls to assign IP address and bring interface up instead of
>> using ifconfig.
>>
>> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> 
> I'm seeing this:
> 
> penberg@tiger:~/linux/tools/kvm$ make
>   GEN      include/common-cmds.h
>   CC       8250-serial.o
>   CC       virtio-blk.o
>   CC       virtio-net.o
> cc1: warnings being treated as errors
> virtio-net.c: In function ‘virtio_net__init’:
> virtio-net.c:302: error: dereferencing pointer ‘({anonymous})’ does
> break strict-aliasing rules
> virtio-net.c:302: note: initialized from here
> make: *** [virtio-net.o] Error 1

Hi, Pekka

I am wondering why is your gcc always stricter than mine?

-- 
Best Regards,
Asias He

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] kvm tools: Set up tun interface using ioctls
  2011-04-13 13:59   ` Asias He
@ 2011-04-13 14:03     ` Pekka Enberg
  0 siblings, 0 replies; 12+ messages in thread
From: Pekka Enberg @ 2011-04-13 14:03 UTC (permalink / raw)
  To: Asias He; +Cc: Sasha Levin, gorcunov, kvm

On Wed, 2011-04-13 at 21:59 +0800, Asias He wrote:
> On 04/13/2011 09:49 PM, Pekka Enberg wrote:
> > On Wed, 13 Apr 2011, Sasha Levin wrote:
> >> Use ioctls to assign IP address and bring interface up instead of
> >> using ifconfig.
> >>
> >> Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > 
> > I'm seeing this:
> > 
> > penberg@tiger:~/linux/tools/kvm$ make
> >   GEN      include/common-cmds.h
> >   CC       8250-serial.o
> >   CC       virtio-blk.o
> >   CC       virtio-net.o
> > cc1: warnings being treated as errors
> > virtio-net.c: In function ‘virtio_net__init’:
> > virtio-net.c:302: error: dereferencing pointer ‘({anonymous})’ does
> > break strict-aliasing rules
> > virtio-net.c:302: note: initialized from here
> > make: *** [virtio-net.o] Error 1
> 
> Hi, Pekka
> 
> I am wondering why is your gcc always stricter than mine?

I have gcc 4.4.3 here. I wouldn't be surprised if those were actually
gcc bugs but and that we should turn off the aliasing checks. However,
for this particular case, it was pretty good at spotting questionable
code so... :-)

			Pekka


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 13:38       ` Sasha Levin
@ 2011-04-13 14:07         ` Pekka Enberg
  2011-04-13 14:13           ` Asias He
  0 siblings, 1 reply; 12+ messages in thread
From: Pekka Enberg @ 2011-04-13 14:07 UTC (permalink / raw)
  To: Sasha Levin; +Cc: Asias He, gorcunov, kvm

On Wed, 2011-04-13 at 16:38 +0300, Sasha Levin wrote:
> On Wed, Apr 13, 2011 at 4:28 PM, Asias He <asias.hejun@gmail.com> wrote:
> > On 04/13/2011 08:28 PM, Asias He wrote:
> >> On 04/13/2011 08:13 PM, Sasha Levin wrote:
> >>> Add --host-ip-addr parameter to allow changing the host-side IP address.
> >>
> >>
> >> I'd personally prefer something like this:
> >>
> >> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy
> >>
> >> Once we can set up ip address for guest, we can use:
> >>
> >> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v
> >>
> >
> >
> > Alternatively, we can use an option group like this:
> >
> > Network options:
> >    -n  --network       <virtio>
> >    -h  --hostip        <x.x.x.x/n>
> >    -y  --guestip       <x.x.x.x/n>
> >    -z  --guestmac      <xx:xx:xx:xx:xx:xx>
> >
> 
> I agree. We can create a networking group once we start expanding the options.

Asias, is the patch OK to merge?


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] kvm tools: Make host side IP configurable
  2011-04-13 14:07         ` Pekka Enberg
@ 2011-04-13 14:13           ` Asias He
  0 siblings, 0 replies; 12+ messages in thread
From: Asias He @ 2011-04-13 14:13 UTC (permalink / raw)
  To: Pekka Enberg; +Cc: Sasha Levin, gorcunov, kvm

On 04/13/2011 10:07 PM, Pekka Enberg wrote:
> On Wed, 2011-04-13 at 16:38 +0300, Sasha Levin wrote:
>> On Wed, Apr 13, 2011 at 4:28 PM, Asias He <asias.hejun@gmail.com> wrote:
>>> On 04/13/2011 08:28 PM, Asias He wrote:
>>>> On 04/13/2011 08:13 PM, Sasha Levin wrote:
>>>>> Add --host-ip-addr parameter to allow changing the host-side IP address.
>>>>
>>>>
>>>> I'd personally prefer something like this:
>>>>
>>>> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy
>>>>
>>>> Once we can set up ip address for guest, we can use:
>>>>
>>>> --network=model=virtio,hostip=x.x.x.x/mask,guestmac=yy:yy:yy:yy,guestip=z.z.z.z/mask,guestgw=v.v.v.v
>>>>
>>>
>>>
>>> Alternatively, we can use an option group like this:
>>>
>>> Network options:
>>>    -n  --network       <virtio>
>>>    -h  --hostip        <x.x.x.x/n>
>>>    -y  --guestip       <x.x.x.x/n>
>>>    -z  --guestmac      <xx:xx:xx:xx:xx:xx>
>>>
>>
>> I agree. We can create a networking group once we start expanding the options.
> 
> Asias, is the patch OK to merge?

The first patch is ok. Sasha needs modification for the second patch.


-- 
Best Regards,
Asias He

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-04-13 14:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-13 12:13 [PATCH 1/2] kvm tools: Set up tun interface using ioctls Sasha Levin
2011-04-13 12:13 ` [PATCH 2/2] kvm tools: Make host side IP configurable Sasha Levin
2011-04-13 12:28   ` Asias He
2011-04-13 12:35     ` Pekka Enberg
2011-04-13 13:28     ` Asias He
2011-04-13 13:38       ` Sasha Levin
2011-04-13 14:07         ` Pekka Enberg
2011-04-13 14:13           ` Asias He
2011-04-13 12:39 ` [PATCH 1/2] kvm tools: Set up tun interface using ioctls Asias He
2011-04-13 13:49 ` Pekka Enberg
2011-04-13 13:59   ` Asias He
2011-04-13 14:03     ` Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox