All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest
@ 2012-03-28  5:40 Jason Wang
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Jason Wang @ 2012-03-28  5:40 UTC (permalink / raw)
  To: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

This an update of series that let guest and qemu to be co-operated to
send gratuitous packets when needed (e.g after migration).

As it's hard for qemu to track the network configuration in guest such
as bondings, vlans or ipv6s. Current gratuitous (RARP packets for
primary mac address) may not work under those situations. The better
method is to allow guest to send them when they can.

The series first introduce a model specific function in order to let
nic models to use a device specific way to announce the link
presence. With this, virtio-net backend were modified to notify the
guest (through config update interrupt) and let guest send the
gratuitous packet when needed.

The first user would be virtio-net.

Changes from V5:

- use a global variable to decide whether an announcement is needed
after migration
- align with virtio spec and let guest ack the announcement
notification through control vq instead of config status writing

Changes from V4:

- keep the old behavior that send the gratuitous packets only after
  migration
- decide whether to send gratuitous packets by previous runstate
  instead of a dedicated parameter
- check virtio_net_started() instead of VIRTIO_NET_S_LINK_UP before
  issue the config update interrupt
- move VIRTIO_NET_S_ANNOUNCE to 0x100 and supress guest config write to RO bits
- cleanups suggested by Michael

---

Jason Wang (4):
      net: announce self after vm start
      net: model specific announcing support
      virtio-net: notify guest to annouce itself
      virtio-net: compat guest announce support


 hw/pc_piix.c    |   35 +++++++++++++++++++++++++++++++++++
 hw/virtio-net.c |   29 +++++++++++++++++++++++++++++
 hw/virtio-net.h |   14 ++++++++++++++
 migration.c     |    2 +-
 migration.h     |    2 ++
 net.h           |    2 ++
 savevm.c        |    8 +++++---
 vl.c            |    5 +++++
 8 files changed, 93 insertions(+), 4 deletions(-)

-- 
Jason Wang

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

* [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start
  2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
@ 2012-03-28  5:40 ` Jason Wang
  2012-03-28  7:22   ` Paolo Bonzini
  2012-05-02  7:49   ` Orit Wasserman
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support Jason Wang
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Jason Wang @ 2012-03-28  5:40 UTC (permalink / raw)
  To: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

qemu_announce_self() were moved to vm_start(). This is because we may
want to let guest to send the gratuitous packets. A global variable
need_announce were introduced to record the pending announcement, and
vm_start() would send gratuitous packet depends on this value.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 migration.c |    2 +-
 migration.h |    2 ++
 vl.c        |    5 +++++
 3 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/migration.c b/migration.c
index 00fa1e3..861cce9 100644
--- a/migration.c
+++ b/migration.c
@@ -88,7 +88,7 @@ void process_incoming_migration(QEMUFile *f)
         fprintf(stderr, "load of migration failed\n");
         exit(0);
     }
-    qemu_announce_self();
+    need_announce = true;
     DPRINTF("successfully loaded vm state\n");
 
     /* Make sure all file formats flush their mutable metadata */
diff --git a/migration.h b/migration.h
index 372b066..0a31463 100644
--- a/migration.h
+++ b/migration.h
@@ -95,4 +95,6 @@ void migrate_add_blocker(Error *reason);
  */
 void migrate_del_blocker(Error *reason);
 
+extern bool need_announce;
+
 #endif
diff --git a/vl.c b/vl.c
index 65f11f2..05ebf57 100644
--- a/vl.c
+++ b/vl.c
@@ -231,6 +231,7 @@ int boot_menu;
 uint8_t *boot_splash_filedata;
 int boot_splash_filedata_size;
 uint8_t qemu_extra_params_fw[2];
+bool need_announce = false;
 
 typedef struct FWBootEntry FWBootEntry;
 
@@ -1266,6 +1267,10 @@ void vm_start(void)
         vm_state_notify(1, RUN_STATE_RUNNING);
         resume_all_vcpus();
         monitor_protocol_event(QEVENT_RESUME, NULL);
+        if (need_announce) {
+            need_announce = false;
+            qemu_announce_self();
+        }
     }
 }
 

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

* [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support
  2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
@ 2012-03-28  5:40 ` Jason Wang
  2012-03-28  7:23   ` Paolo Bonzini
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 3/4] virtio-net: notify guest to annouce itself Jason Wang
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Jason Wang @ 2012-03-28  5:40 UTC (permalink / raw)
  To: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

This patch introduces a function pointer in NetClientInfo which is
called during self announcement. With this, each kind of card can
announce the link with a specific way. The old method is still kept
for cards that have not implemented this or old guest. The first user
would be virtio-net.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 net.h    |    2 ++
 savevm.c |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/net.h b/net.h
index 75a8c15..7195bfc 100644
--- a/net.h
+++ b/net.h
@@ -48,6 +48,7 @@ typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
 typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
 typedef void (NetCleanup) (VLANClientState *);
 typedef void (LinkStatusChanged)(VLANClientState *);
+typedef int (NetAnnounce)(VLANClientState *);
 
 typedef struct NetClientInfo {
     net_client_type type;
@@ -59,6 +60,7 @@ typedef struct NetClientInfo {
     NetCleanup *cleanup;
     LinkStatusChanged *link_status_changed;
     NetPoll *poll;
+    NetAnnounce *announce;
 } NetClientInfo;
 
 struct VLANClientState {
diff --git a/savevm.c b/savevm.c
index 80be1ff..7558c1d 100644
--- a/savevm.c
+++ b/savevm.c
@@ -123,10 +123,12 @@ static void qemu_announce_self_iter(NICState *nic, void *opaque)
 {
     uint8_t buf[60];
     int len;
+    NetAnnounce *func = nic->nc.info->announce;
 
-    len = announce_self_create(buf, nic->conf->macaddr.a);
-
-    qemu_send_packet_raw(&nic->nc, buf, len);
+    if (!func || func(&nic->nc) != 0) {
+        len = announce_self_create(buf, nic->conf->macaddr.a);
+        qemu_send_packet_raw(&nic->nc, buf, len);
+    }
 }
 
 

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

* [Qemu-devel] [V6 PATCH 3/4] virtio-net: notify guest to annouce itself
  2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support Jason Wang
@ 2012-03-28  5:40 ` Jason Wang
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 4/4] virtio-net: compat guest announce support Jason Wang
  2012-05-02  3:51 ` [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
  4 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2012-03-28  5:40 UTC (permalink / raw)
  To: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

It's hard to track all mac addresses and their usage (vlan, bondings,
ipv6) in qemu to send proper gratuitous packet. The better choice is
to let guest to send them.

So, this patch introduces a new rw config status bit of virtio-net,
VIRTIO_NET_S_ANNOUNCE which is used to notify guest to announce
presence of its link through config update interrupt. When gust have
done the announcement, it should ack the notification through
VIRTIO_NET_CTRL_ANNOUNCE_ACK cmd. This feature is negotiated by
a new feature bit VIRTIO_NET_F_ANNOUNCE.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/virtio-net.c |   29 +++++++++++++++++++++++++++++
 hw/virtio-net.h |   14 ++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index bc5e3a8..039b7fd 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -404,6 +404,17 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
     return VIRTIO_NET_OK;
 }
 
+static int virtio_net_handle_announce(VirtIONet *n, uint8_t cmd,
+                                      VirtQueueElement *elem)
+{
+    if (cmd == VIRTIO_NET_CTRL_ANNOUNCE_ACK) {
+        n->status &= ~VIRTIO_NET_S_ANNOUNCE;
+        return VIRTIO_NET_OK;
+    } else {
+        return VIRTIO_NET_ERR;
+    }
+}
+
 static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIONet *n = to_virtio_net(vdev);
@@ -432,6 +443,8 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
             status = virtio_net_handle_mac(n, ctrl.cmd, &elem);
         else if (ctrl.class == VIRTIO_NET_CTRL_VLAN)
             status = virtio_net_handle_vlan_table(n, ctrl.cmd, &elem);
+        else if (ctrl.class == VIRTIO_NET_CTRL_ANNOUNCE)
+            status = virtio_net_handle_announce(n, ctrl.cmd, &elem);
 
         stb_p(elem.in_sg[elem.in_num - 1].iov_base, status);
 
@@ -983,6 +996,21 @@ static void virtio_net_cleanup(VLANClientState *nc)
     n->nic = NULL;
 }
 
+static int virtio_net_announce(VLANClientState *nc)
+{
+    VirtIONet *n = DO_UPCAST(NICState, nc, nc)->opaque;
+
+    if (n->vdev.guest_features & (0x1 << VIRTIO_NET_F_GUEST_ANNOUNCE)
+        && n->vdev.guest_features & (0x1 << VIRTIO_NET_F_CTRL_VQ)
+        && virtio_net_started(n, n->vdev.status)) {
+        n->status |= VIRTIO_NET_S_ANNOUNCE;
+        virtio_notify_config(&n->vdev);
+        return 0;
+    }
+
+    return -1;
+}
+
 static NetClientInfo net_virtio_info = {
     .type = NET_CLIENT_TYPE_NIC,
     .size = sizeof(NICState),
@@ -990,6 +1018,7 @@ static NetClientInfo net_virtio_info = {
     .receive = virtio_net_receive,
         .cleanup = virtio_net_cleanup,
     .link_status_changed = virtio_net_set_link_status,
+    .announce = virtio_net_announce,
 };
 
 VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 4468741..9e45786 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -44,8 +44,10 @@
 #define VIRTIO_NET_F_CTRL_RX    18      /* Control channel RX mode support */
 #define VIRTIO_NET_F_CTRL_VLAN  19      /* Control channel VLAN filtering */
 #define VIRTIO_NET_F_CTRL_RX_EXTRA 20   /* Extra RX mode control support */
+#define VIRTIO_NET_F_GUEST_ANNOUNCE 21  /* Guest can announce itself */
 
 #define VIRTIO_NET_S_LINK_UP    1       /* Link is up */
+#define VIRTIO_NET_S_ANNOUNCE   2       /* Announcement is needed */
 
 #define TX_TIMER_INTERVAL 150000 /* 150 us */
 
@@ -167,6 +169,17 @@ struct virtio_net_ctrl_mac {
  #define VIRTIO_NET_CTRL_VLAN_ADD             0
  #define VIRTIO_NET_CTRL_VLAN_DEL             1
 
+/*
+ * Control link announce acknowledgement
+ *
+ * The command VIRTIO_NET_CTRL_ANNOUNCE_ACK is used to indicate that
+ * driver has recevied the notification and device would clear the
+ * VIRTIO_NET_S_ANNOUNCE bit in the status filed after it received
+ * this command.
+ */
+#define VIRTIO_NET_CTRL_ANNOUNCE       3
+ #define VIRTIO_NET_CTRL_ANNOUNCE_ACK         0
+
 #define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \
         DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
         DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \
@@ -176,6 +189,7 @@ struct virtio_net_ctrl_mac {
         DEFINE_PROP_BIT("guest_tso6", _state, _field, VIRTIO_NET_F_GUEST_TSO6, true), \
         DEFINE_PROP_BIT("guest_ecn", _state, _field, VIRTIO_NET_F_GUEST_ECN, true), \
         DEFINE_PROP_BIT("guest_ufo", _state, _field, VIRTIO_NET_F_GUEST_UFO, true), \
+        DEFINE_PROP_BIT("guest_announce", _state, _field, VIRTIO_NET_F_GUEST_ANNOUNCE, true), \
         DEFINE_PROP_BIT("host_tso4", _state, _field, VIRTIO_NET_F_HOST_TSO4, true), \
         DEFINE_PROP_BIT("host_tso6", _state, _field, VIRTIO_NET_F_HOST_TSO6, true), \
         DEFINE_PROP_BIT("host_ecn", _state, _field, VIRTIO_NET_F_HOST_ECN, true), \

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

* [Qemu-devel] [V6 PATCH 4/4] virtio-net: compat guest announce support.
  2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
                   ` (2 preceding siblings ...)
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 3/4] virtio-net: notify guest to annouce itself Jason Wang
@ 2012-03-28  5:40 ` Jason Wang
  2012-05-02  3:51 ` [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
  4 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2012-03-28  5:40 UTC (permalink / raw)
  To: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

Disable guest announce for compat machine types.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/pc_piix.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 6c5c40f..780b607 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -389,6 +389,11 @@ static QEMUMachine pc_machine_v1_0 = {
             .property = "check_media_rate",
             .value    = "off",
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     },
 };
@@ -408,6 +413,11 @@ static QEMUMachine pc_machine_v0_15 = {
             .property = "check_media_rate",
             .value    = "off",
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     },
 };
@@ -452,6 +462,11 @@ static QEMUMachine pc_machine_v0_14 = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     },
 };
@@ -508,6 +523,11 @@ static QEMUMachine pc_machine_v0_13 = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     },
 };
@@ -568,6 +588,11 @@ static QEMUMachine pc_machine_v0_12 = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     }
 };
@@ -636,6 +661,11 @@ static QEMUMachine pc_machine_v0_11 = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     }
 };
@@ -716,6 +746,11 @@ static QEMUMachine pc_machine_v0_10 = {
             .property = "rom_only",
             .value    = stringify(1),
         },
+        {
+            .driver   = "virtio-net-pci",
+            .property = "guest_announce",
+            .value    = "off",
+        },
         { /* end of list */ }
     },
 };

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

* Re: [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
@ 2012-03-28  7:22   ` Paolo Bonzini
  2012-05-02  7:49   ` Orit Wasserman
  1 sibling, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2012-03-28  7:22 UTC (permalink / raw)
  To: Jason Wang; +Cc: aliguori, stefanha, mst, rusty, qemu-devel, quintela

Il 28/03/2012 07:40, Jason Wang ha scritto:
> qemu_announce_self() were moved to vm_start(). This is because we may
> want to let guest to send the gratuitous packets. A global variable
> need_announce were introduced to record the pending announcement, and
> vm_start() would send gratuitous packet depends on this value.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  migration.c |    2 +-
>  migration.h |    2 ++
>  vl.c        |    5 +++++
>  3 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 00fa1e3..861cce9 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -88,7 +88,7 @@ void process_incoming_migration(QEMUFile *f)
>          fprintf(stderr, "load of migration failed\n");
>          exit(0);
>      }
> -    qemu_announce_self();
> +    need_announce = true;
>      DPRINTF("successfully loaded vm state\n");
>  
>      /* Make sure all file formats flush their mutable metadata */
> diff --git a/migration.h b/migration.h
> index 372b066..0a31463 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -95,4 +95,6 @@ void migrate_add_blocker(Error *reason);
>   */
>  void migrate_del_blocker(Error *reason);
>  
> +extern bool need_announce;
> +
>  #endif
> diff --git a/vl.c b/vl.c
> index 65f11f2..05ebf57 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -231,6 +231,7 @@ int boot_menu;
>  uint8_t *boot_splash_filedata;
>  int boot_splash_filedata_size;
>  uint8_t qemu_extra_params_fw[2];
> +bool need_announce = false;
>  
>  typedef struct FWBootEntry FWBootEntry;
>  
> @@ -1266,6 +1267,10 @@ void vm_start(void)
>          vm_state_notify(1, RUN_STATE_RUNNING);
>          resume_all_vcpus();
>          monitor_protocol_event(QEVENT_RESUME, NULL);
> +        if (need_announce) {
> +            need_announce = false;
> +            qemu_announce_self();
> +        }
>      }
>  }
>  
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

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

* Re: [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support Jason Wang
@ 2012-03-28  7:23   ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2012-03-28  7:23 UTC (permalink / raw)
  To: Jason Wang; +Cc: aliguori, stefanha, mst, rusty, qemu-devel, quintela

Il 28/03/2012 07:40, Jason Wang ha scritto:
> This patch introduces a function pointer in NetClientInfo which is
> called during self announcement. With this, each kind of card can
> announce the link with a specific way. The old method is still kept
> for cards that have not implemented this or old guest. The first user
> would be virtio-net.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  net.h    |    2 ++
>  savevm.c |    8 +++++---
>  2 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/net.h b/net.h
> index 75a8c15..7195bfc 100644
> --- a/net.h
> +++ b/net.h
> @@ -48,6 +48,7 @@ typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
>  typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
>  typedef void (NetCleanup) (VLANClientState *);
>  typedef void (LinkStatusChanged)(VLANClientState *);
> +typedef int (NetAnnounce)(VLANClientState *);
>  
>  typedef struct NetClientInfo {
>      net_client_type type;
> @@ -59,6 +60,7 @@ typedef struct NetClientInfo {
>      NetCleanup *cleanup;
>      LinkStatusChanged *link_status_changed;
>      NetPoll *poll;
> +    NetAnnounce *announce;
>  } NetClientInfo;
>  
>  struct VLANClientState {
> diff --git a/savevm.c b/savevm.c
> index 80be1ff..7558c1d 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -123,10 +123,12 @@ static void qemu_announce_self_iter(NICState *nic, void *opaque)
>  {
>      uint8_t buf[60];
>      int len;
> +    NetAnnounce *func = nic->nc.info->announce;
>  
> -    len = announce_self_create(buf, nic->conf->macaddr.a);
> -
> -    qemu_send_packet_raw(&nic->nc, buf, len);
> +    if (!func || func(&nic->nc) != 0) {
> +        len = announce_self_create(buf, nic->conf->macaddr.a);
> +        qemu_send_packet_raw(&nic->nc, buf, len);
> +    }
>  }
>  
>  
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

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

* Re: [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest
  2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
                   ` (3 preceding siblings ...)
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 4/4] virtio-net: compat guest announce support Jason Wang
@ 2012-05-02  3:51 ` Jason Wang
  4 siblings, 0 replies; 11+ messages in thread
From: Jason Wang @ 2012-05-02  3:51 UTC (permalink / raw)
  To: stefanha, quintela, rusty, qemu-devel, mst, pbonzini, aliguori

Hi Anthony:

Any more comments on the series?

Thanks

----- Original Message -----
> This an update of series that let guest and qemu to be co-operated to
> send gratuitous packets when needed (e.g after migration).
> 
> As it's hard for qemu to track the network configuration in guest
> such
> as bondings, vlans or ipv6s. Current gratuitous (RARP packets for
> primary mac address) may not work under those situations. The better
> method is to allow guest to send them when they can.
> 
> The series first introduce a model specific function in order to let
> nic models to use a device specific way to announce the link
> presence. With this, virtio-net backend were modified to notify the
> guest (through config update interrupt) and let guest send the
> gratuitous packet when needed.
> 
> The first user would be virtio-net.
> 
> Changes from V5:
> 
> - use a global variable to decide whether an announcement is needed
> after migration
> - align with virtio spec and let guest ack the announcement
> notification through control vq instead of config status writing
> 
> Changes from V4:
> 
> - keep the old behavior that send the gratuitous packets only after
>   migration
> - decide whether to send gratuitous packets by previous runstate
>   instead of a dedicated parameter
> - check virtio_net_started() instead of VIRTIO_NET_S_LINK_UP before
>   issue the config update interrupt
> - move VIRTIO_NET_S_ANNOUNCE to 0x100 and supress guest config write
> to RO bits
> - cleanups suggested by Michael
> 
> ---
> 
> Jason Wang (4):
>       net: announce self after vm start
>       net: model specific announcing support
>       virtio-net: notify guest to annouce itself
>       virtio-net: compat guest announce support
> 
> 
>  hw/pc_piix.c    |   35 +++++++++++++++++++++++++++++++++++
>  hw/virtio-net.c |   29 +++++++++++++++++++++++++++++
>  hw/virtio-net.h |   14 ++++++++++++++
>  migration.c     |    2 +-
>  migration.h     |    2 ++
>  net.h           |    2 ++
>  savevm.c        |    8 +++++---
>  vl.c            |    5 +++++
>  8 files changed, 93 insertions(+), 4 deletions(-)
> 
> --
> Jason Wang
> 
> 

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

* Re: [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start
  2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
  2012-03-28  7:22   ` Paolo Bonzini
@ 2012-05-02  7:49   ` Orit Wasserman
  2012-05-02  7:59     ` Jason Wang
  1 sibling, 1 reply; 11+ messages in thread
From: Orit Wasserman @ 2012-05-02  7:49 UTC (permalink / raw)
  To: Jason Wang; +Cc: aliguori, stefanha, mst, rusty, qemu-devel, quintela, pbonzini

On 03/28/2012 07:40 AM, Jason Wang wrote:
> qemu_announce_self() were moved to vm_start(). This is because we may
> want to let guest to send the gratuitous packets. A global variable
> need_announce were introduced to record the pending announcement, and
> vm_start() would send gratuitous packet depends on this value.
> 
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  migration.c |    2 +-
>  migration.h |    2 ++
>  vl.c        |    5 +++++
>  3 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/migration.c b/migration.c
> index 00fa1e3..861cce9 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -88,7 +88,7 @@ void process_incoming_migration(QEMUFile *f)
>          fprintf(stderr, "load of migration failed\n");
>          exit(0);
>      }
> -    qemu_announce_self();
> +    need_announce = true;
>      DPRINTF("successfully loaded vm state\n");
>  
>      /* Make sure all file formats flush their mutable metadata */
> diff --git a/migration.h b/migration.h
> index 372b066..0a31463 100644
> --- a/migration.h
> +++ b/migration.h
> @@ -95,4 +95,6 @@ void migrate_add_blocker(Error *reason);
>   */
>  void migrate_del_blocker(Error *reason);
>  
> +extern bool need_announce;
> +
Hi Jason,
I don't like this external flag.
As this is only related to migration I think we can add a new state RUN_STATE_MIG_PRELAUNCH.
In vm_start call qemu_announce_self only if the state was RUN_STATE_MIG_PRELAUNCH.
This will we useful if we will need to do something else when resuming a migrated guest.

Regards,
Orit

>  #endif
> diff --git a/vl.c b/vl.c
> index 65f11f2..05ebf57 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -231,6 +231,7 @@ int boot_menu;
>  uint8_t *boot_splash_filedata;
>  int boot_splash_filedata_size;
>  uint8_t qemu_extra_params_fw[2];
> +bool need_announce = false;
>  
>  typedef struct FWBootEntry FWBootEntry;
>  
> @@ -1266,6 +1267,10 @@ void vm_start(void)
>          vm_state_notify(1, RUN_STATE_RUNNING);
>          resume_all_vcpus();
>          monitor_protocol_event(QEVENT_RESUME, NULL);
> +        if (need_announce) {
> +            need_announce = false;
> +            qemu_announce_self();
> +        }
>      }
>  }
>  
> 
> 

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

* Re: [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start
  2012-05-02  7:49   ` Orit Wasserman
@ 2012-05-02  7:59     ` Jason Wang
  2012-05-02  8:32       ` Paolo Bonzini
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Wang @ 2012-05-02  7:59 UTC (permalink / raw)
  To: Orit Wasserman
  Cc: aliguori, stefanha, quintela, rusty, qemu-devel, mst, pbonzini

On 05/02/2012 03:49 PM, Orit Wasserman wrote:
> On 03/28/2012 07:40 AM, Jason Wang wrote:
>> qemu_announce_self() were moved to vm_start(). This is because we may
>> want to let guest to send the gratuitous packets. A global variable
>> need_announce were introduced to record the pending announcement, and
>> vm_start() would send gratuitous packet depends on this value.
>>
>> Signed-off-by: Jason Wang<jasowang@redhat.com>
>> ---
>>   migration.c |    2 +-
>>   migration.h |    2 ++
>>   vl.c        |    5 +++++
>>   3 files changed, 8 insertions(+), 1 deletions(-)
>>
>> diff --git a/migration.c b/migration.c
>> index 00fa1e3..861cce9 100644
>> --- a/migration.c
>> +++ b/migration.c
>> @@ -88,7 +88,7 @@ void process_incoming_migration(QEMUFile *f)
>>           fprintf(stderr, "load of migration failed\n");
>>           exit(0);
>>       }
>> -    qemu_announce_self();
>> +    need_announce = true;
>>       DPRINTF("successfully loaded vm state\n");
>>
>>       /* Make sure all file formats flush their mutable metadata */
>> diff --git a/migration.h b/migration.h
>> index 372b066..0a31463 100644
>> --- a/migration.h
>> +++ b/migration.h
>> @@ -95,4 +95,6 @@ void migrate_add_blocker(Error *reason);
>>    */
>>   void migrate_del_blocker(Error *reason);
>>
>> +extern bool need_announce;
>> +
> Hi Jason,
> I don't like this external flag.
> As this is only related to migration I think we can add a new state RUN_STATE_MIG_PRELAUNCH.
> In vm_start call qemu_announce_self only if the state was RUN_STATE_MIG_PRELAUNCH.
> This will we useful if we will need to do something else when resuming a migrated guest.
>
> Regards,
> Orit
Hi Orit:

No problem, the only reason of using global variable is simplicity, we 
thought to add one new run state in the past. I would add one like what 
you suggested.

Thanks

>>   #endif
>> diff --git a/vl.c b/vl.c
>> index 65f11f2..05ebf57 100644
>> --- a/vl.c
>> +++ b/vl.c
>> @@ -231,6 +231,7 @@ int boot_menu;
>>   uint8_t *boot_splash_filedata;
>>   int boot_splash_filedata_size;
>>   uint8_t qemu_extra_params_fw[2];
>> +bool need_announce = false;
>>
>>   typedef struct FWBootEntry FWBootEntry;
>>
>> @@ -1266,6 +1267,10 @@ void vm_start(void)
>>           vm_state_notify(1, RUN_STATE_RUNNING);
>>           resume_all_vcpus();
>>           monitor_protocol_event(QEVENT_RESUME, NULL);
>> +        if (need_announce) {
>> +            need_announce = false;
>> +            qemu_announce_self();
>> +        }
>>       }
>>   }
>>
>>
>>
>

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

* Re: [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start
  2012-05-02  7:59     ` Jason Wang
@ 2012-05-02  8:32       ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2012-05-02  8:32 UTC (permalink / raw)
  To: Jason Wang
  Cc: aliguori, stefanha, mst, rusty, qemu-devel, Orit Wasserman, quintela

Il 02/05/2012 09:59, Jason Wang ha scritto:
> I don't like this external flag. As this is only related to migration
> I think we can add a new state RUN_STATE_MIG_PRELAUNCH. In vm_start
> call qemu_announce_self only if the state was 
> RUN_STATE_MIG_PRELAUNCH. This will we useful if we will need to do
> something else when resuming a migrated guest.

I don't think this global is replacing a runstate.  It is simply saying
that some work has been delayed to the next time the CPU runs.

Perhaps we can instead use a runstate-change notifier and keep the
global hidden to vl.c.

Paolo

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

end of thread, other threads:[~2012-05-02  8:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-28  5:40 [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang
2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 1/4] net: announce self after vm start Jason Wang
2012-03-28  7:22   ` Paolo Bonzini
2012-05-02  7:49   ` Orit Wasserman
2012-05-02  7:59     ` Jason Wang
2012-05-02  8:32       ` Paolo Bonzini
2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 2/4] net: model specific announcing support Jason Wang
2012-03-28  7:23   ` Paolo Bonzini
2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 3/4] virtio-net: notify guest to annouce itself Jason Wang
2012-03-28  5:40 ` [Qemu-devel] [V6 PATCH 4/4] virtio-net: compat guest announce support Jason Wang
2012-05-02  3:51 ` [Qemu-devel] [V6 PATCH 0/4] Send gratuitous packets by guest Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.