1. 02 11月, 2016 1 次提交
  2. 29 10月, 2016 1 次提交
  3. 28 10月, 2016 1 次提交
  4. 26 10月, 2016 2 次提交
  5. 24 10月, 2016 8 次提交
  6. 12 10月, 2016 1 次提交
  7. 10 10月, 2016 1 次提交
    • D
      net: don't poke at chardev internal QemuOpts · 0a73336d
      Daniel P. Berrange 提交于
      The vhost-user & colo code is poking at the QemuOpts instance
      in the CharDriverState struct, not realizing that it is valid
      for this to be NULL. e.g. the following crash shows a codepath
      where it will be NULL:
      
       Program terminated with signal SIGSEGV, Segmentation fault.
       #0  0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
       617         QTAILQ_FOREACH(opt, &opts->head, next) {
       [Current thread is 1 (Thread 0x7f1d4970bb40 (LWP 6603))]
       (gdb) bt
       #0  0x000055baf6ab4adc in qemu_opt_foreach (opts=0x0, func=0x55baf696b650 <net_vhost_chardev_opts>, opaque=0x7ffc51368c00, errp=0x7ffc51368e48) at util/qemu-option.c:617
       #1  0x000055baf696b7da in net_vhost_parse_chardev (opts=0x55baf8ff9260, errp=0x7ffc51368e48) at net/vhost-user.c:314
       #2  0x000055baf696b985 in net_init_vhost_user (netdev=0x55baf8ff9250, name=0x55baf879d270 "hostnet2", peer=0x0, errp=0x7ffc51368e48) at net/vhost-user.c:360
       #3  0x000055baf6960216 in net_client_init1 (object=0x55baf8ff9250, is_netdev=true, errp=0x7ffc51368e48) at net/net.c:1051
       #4  0x000055baf6960518 in net_client_init (opts=0x55baf776e7e0, is_netdev=true, errp=0x7ffc51368f00) at net/net.c:1108
       #5  0x000055baf696083f in netdev_add (opts=0x55baf776e7e0, errp=0x7ffc51368f00) at net/net.c:1186
       #6  0x000055baf69608c7 in qmp_netdev_add (qdict=0x55baf7afaf60, ret=0x7ffc51368f50, errp=0x7ffc51368f48) at net/net.c:1205
       #7  0x000055baf6622135 in handle_qmp_command (parser=0x55baf77fb590, tokens=0x7f1d24011960) at /path/to/qemu.git/monitor.c:3978
       #8  0x000055baf6a9d099 in json_message_process_token (lexer=0x55baf77fb598, input=0x55baf75acd20, type=JSON_RCURLY, x=113, y=19) at qobject/json-streamer.c:105
       #9  0x000055baf6abf7aa in json_lexer_feed_char (lexer=0x55baf77fb598, ch=125 '}', flush=false) at qobject/json-lexer.c:319
       #10 0x000055baf6abf8f2 in json_lexer_feed (lexer=0x55baf77fb598, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-lexer.c:369
       #11 0x000055baf6a9d13c in json_message_parser_feed (parser=0x55baf77fb590, buffer=0x7ffc51369170 "}R\204\367\272U", size=1) at qobject/json-streamer.c:124
       #12 0x000055baf66221f7 in monitor_qmp_read (opaque=0x55baf77fb530, buf=0x7ffc51369170 "}R\204\367\272U", size=1) at /path/to/qemu.git/monitor.c:3994
       #13 0x000055baf6757014 in qemu_chr_be_write_impl (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:387
       #14 0x000055baf6757076 in qemu_chr_be_write (s=0x55baf7610a40, buf=0x7ffc51369170 "}R\204\367\272U", len=1) at qemu-char.c:399
       #15 0x000055baf675b3b0 in tcp_chr_read (chan=0x55baf90244b0, cond=G_IO_IN, opaque=0x55baf7610a40) at qemu-char.c:2927
       #16 0x000055baf6a5d655 in qio_channel_fd_source_dispatch (source=0x55baf7610df0, callback=0x55baf675b25a <tcp_chr_read>, user_data=0x55baf7610a40) at io/channel-watch.c:84
       #17 0x00007f1d3e80cbbd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
       #18 0x000055baf69d3720 in glib_pollfds_poll () at main-loop.c:213
       #19 0x000055baf69d37fd in os_host_main_loop_wait (timeout=126000000) at main-loop.c:258
       #20 0x000055baf69d38ad in main_loop_wait (nonblocking=0) at main-loop.c:506
       #21 0x000055baf676587b in main_loop () at vl.c:1908
       #22 0x000055baf676d3bf in main (argc=101, argv=0x7ffc5136a6c8, envp=0x7ffc5136a9f8) at vl.c:4604
       (gdb) p opts
       $1 = (QemuOpts *) 0x0
      
      The crash occurred when attaching vhost-user net via QMP:
      
      {
          "execute": "chardev-add",
          "arguments": {
              "id": "charnet2",
              "backend": {
                  "type": "socket",
                  "data": {
                      "addr": {
                          "type": "unix",
                          "data": {
                              "path": "/var/run/openvswitch/vhost-user1"
                          }
                      },
                      "wait": false,
                      "server": false
                  }
              }
          },
          "id": "libvirt-19"
      }
      {
          "return": {
      
          },
          "id": "libvirt-19"
      }
      {
          "execute": "netdev_add",
          "arguments": {
              "type": "vhost-user",
              "chardev": "charnet2",
              "id": "hostnet2"
          },
          "id": "libvirt-20"
      }
      
      Code using chardevs should not be poking at the internals of the
      CharDriverState struct. What vhost-user wants is a chardev that is
      operating as reconnectable network service, along with the ability
      to do FD passing over the connection. The colo code simply wants
      a network service. Add a feature concept to the char drivers so
      that chardev users can query the actual features they wish to have
      supported. The QemuOpts member is removed to prevent future mistakes
      in this area.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0a73336d
  8. 08 10月, 2016 1 次提交
  9. 27 9月, 2016 12 次提交
    • P
      net: limit allocation in nc_sendv_compat · 47f9f158
      Peter Lieven 提交于
      we only need to allocate enough memory to hold the packet. This might be
      less than NET_BUFSIZE. Additionally fail early if the packet is larger
      than NET_BUFSIZE.
      Signed-off-by: NPeter Lieven <pl@kamp.de>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      47f9f158
    • A
      tap: Allow specifying a bridge · 584613ea
      Alexey Kardashevskiy 提交于
      The tap backend is already using qemu-bridge-helper to attach tap
      interface to a bridge but (unlike the bridge backend) it always uses
      the default bridge name - br0.
      
      This adds a "br" property support to the tap backend.
      Signed-off-by: NAlexey Kardashevskiy <aik@ozlabs.ru>
      Reviewed-by: NGreg Kurz <groug@kaod.org>
      Tested-by: NGreg Kurz <groug@kaod.org>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      584613ea
    • Z
      filter-rewriter: rewrite tcp packet to keep secondary connection · 30656b09
      Zhang Chen 提交于
      We will rewrite tcp packet secondary received and sent.
      When colo guest is a tcp server.
      
      Firstly, client start a tcp handshake. the packet's seq=client_seq,
      ack=0,flag=SYN. COLO primary guest get this pkt and mirror(filter-mirror)
      to secondary guest, secondary get it use filter-redirector.
      Then,primary guest response pkt
      (seq=primary_seq,ack=client_seq+1,flag=ACK|SYN).
      secondary guest response pkt
      (seq=secondary_seq,ack=client_seq+1,flag=ACK|SYN).
      In here,we use filter-rewriter save the secondary_seq to it's tcp connection.
      Finally handshake,client send pkt
      (seq=client_seq+1,ack=primary_seq+1,flag=ACK).
      Here,filter-rewriter can get primary_seq, and rewrite ack from primary_seq+1
      to secondary_seq+1, recalculate checksum. So the secondary tcp connection
      kept good.
      
      When we send/recv packet.
      client send pkt(seq=client_seq+1+data_len,ack=primary_seq+1,flag=ACK|PSH).
      filter-rewriter rewrite ack and send to secondary guest.
      
      primary guest response pkt
      (seq=primary_seq+1,ack=client_seq+1+data_len,flag=ACK)
      secondary guest response pkt
      (seq=secondary_seq+1,ack=client_seq+1+data_len,flag=ACK)
      we rewrite secondary guest seq from secondary_seq+1 to primary_seq+1.
      So tcp connection kept good.
      
      In code We use offset( = secondary_seq - primary_seq )
      to rewrite seq or ack.
      handle_primary_tcp_pkt: tcp_pkt->th_ack += offset;
      handle_secondary_tcp_pkt: tcp_pkt->th_seq -= offset;
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      30656b09
    • Z
      filter-rewriter: track connection and parse packet · afe46124
      Zhang Chen 提交于
      We use net/colo.h to track connection and parse packet
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      afe46124
    • Z
      filter-rewriter: introduce filter-rewriter initialization · e6eee8ab
      Zhang Chen 提交于
      Filter-rewriter is a part of COLO project.
      It will rewrite some of secondary packet to make
      secondary guest's tcp connection established successfully.
      In this module we will rewrite tcp packet's ack to the secondary
      from primary,and rewrite tcp packet's seq to the primary from
      secondary.
      
      usage:
      
      colo secondary:
      -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
      -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
      -object filter-rewriter,id=rew0,netdev=hn0,queue=all
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      e6eee8ab
    • Z
      colo-compare: add TCP, UDP, ICMP packet comparison · f4b61836
      Zhang Chen 提交于
      We add TCP,UDP,ICMP packet comparison to replace
      IP packet comparison. This can increase the
      accuracy of the package comparison.
      Less checkpoint more efficiency.
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      f4b61836
    • Z
      colo-compare: introduce packet comparison thread · 0682e15b
      Zhang Chen 提交于
      If primary packet is same with secondary packet,
      we will send primary packet and drop secondary
      packet, otherwise notify COLO frame to do checkpoint.
      If primary packet comes but secondary packet does not,
      after REGULAR_PACKET_CHECK_MS milliseconds we set
      the primary packet as old_packet,then do a checkpoint.
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      0682e15b
    • Z
      colo-compare: track connection and enqueue packet · b6540d40
      Zhang Chen 提交于
      In this patch we use kernel jhash table to track
      connection, and then enqueue net packet like this:
      
      + CompareState ++
      |               |
      +---------------+   +---------------+         +---------------+
      |conn list      +--->conn           +--------->conn           |
      +---------------+   +---------------+         +---------------+
      |               |     |           |             |          |
      +---------------+ +---v----+  +---v----+    +---v----+ +---v----+
                        |primary |  |secondary    |primary | |secondary
                        |packet  |  |packet  +    |packet  | |packet  +
                        +--------+  +--------+    +--------+ +--------+
                            |           |             |          |
                        +---v----+  +---v----+    +---v----+ +---v----+
                        |primary |  |secondary    |primary | |secondary
                        |packet  |  |packet  +    |packet  | |packet  +
                        +--------+  +--------+    +--------+ +--------+
                            |           |             |          |
                        +---v----+  +---v----+    +---v----+ +---v----+
                        |primary |  |secondary    |primary | |secondary
                        |packet  |  |packet  +    |packet  | |packet  +
                        +--------+  +--------+    +--------+ +--------+
      
      We use conn_list to record connection info.
      When we want to enqueue a packet, firstly get the
      connection from connection_track_table. then push
      the packet to g_queue(pri/sec) in it's own conn.
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      b6540d40
    • Z
      Jhash: add linux kernel jhashtable in qemu · ccf0426c
      Zhang Chen 提交于
      Jhash will be used by colo-compare and filter-rewriter
      to save and lookup net connection info
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      ccf0426c
    • Z
      net/colo.c: add colo.c to define and handle packet · 59509ec1
      Zhang Chen 提交于
      The net/colo.c is used by colo-compare and filter-rewriter.
      this can share common data structure like net packet,
      and other functions.
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      59509ec1
    • Z
      colo-compare: introduce colo compare initialization · 7dce4e6f
      Zhang Chen 提交于
      This a COLO net ascii figure:
      
       Primary qemu                                                           Secondary qemu
      +--------------------------------------------------------------+       +----------------------------------------------------------------+
      | +----------------------------------------------------------+ |       |  +-----------------------------------------------------------+ |
      | |                                                          | |       |  |                                                           | |
      | |                        guest                             | |       |  |                        guest                              | |
      | |                                                          | |       |  |                                                           | |
      | +-------^--------------------------+-----------------------+ |       |  +---------------------+--------+----------------------------+ |
      |         |                          |                         |       |                        ^        |                              |
      |         |                          |                         |       |                        |        |                              |
      |         |  +------------------------------------------------------+  |                        |        |                              |
      |netfilter|  |                       |                         |    |  |   netfilter            |        |                              |
      | +----------+ +----------------------------+                  |    |  |  +-----------------------------------------------------------+ |
      | |       |  |                       |      |        out       |    |  |  |                     |        |  filter excute order       | |
      | |       |  |          +-----------------------------+        |    |  |  |                     |        | +------------------->      | |
      | |       |  |          |            |      |         |        |    |  |  |                     |        |   TCP                      | |
      | | +-----+--+-+  +-----v----+ +-----v----+ |pri +----+----+sec|    |  |  | +------------+  +---+----+---v+rewriter++  +------------+ | |
      | | |          |  |          | |          | |in  |         |in |    |  |  | |            |  |        |              |  |            | | |
      | | |  filter  |  |  filter  | |  filter  +------>  colo   <------+ +-------->  filter   +--> adjust |   adjust     +-->   filter   | | |
      | | |  mirror  |  |redirector| |redirector| |    | compare |   |  |    |  | | redirector |  | ack    |   seq        |  | redirector | | |
      | | |          |  |          | |          | |    |         |   |  |    |  | |            |  |        |              |  |            | | |
      | | +----^-----+  +----+-----+ +----------+ |    +---------+   |  |    |  | +------------+  +--------+--------------+  +---+--------+ | |
      | |      |   tx        |   rx           rx  |                  |  |    |  |            tx                        all       |  rx      | |
      | |      |             |                    |                  |  |    |  +-----------------------------------------------------------+ |
      | |      |             +--------------+     |                  |  |    |                                                   |            |
      | |      |   filter excute order      |     |                  |  |    |                                                   |            |
      | |      |  +---------------->        |     |                  |  +--------------------------------------------------------+            |
      | +-----------------------------------------+                  |       |                                                                |
      |        |                            |                        |       |                                                                |
      +--------------------------------------------------------------+       +----------------------------------------------------------------+
               |guest receive               | guest send
               |                            |
      +--------+----------------------------v------------------------+
      |                                                              |                          NOTE: filter direction is rx/tx/all
      |                         tap                                  |                          rx:receive packets sent to the netdev
      |                                                              |                          tx:receive packets sent by the netdev
      +--------------------------------------------------------------+
      
      In COLO-compare, we do packet comparing job.
      Packets coming from the primary char indev will be sent to outdev.
      Packets coming from the secondary char dev will be dropped after comparing.
      colo-comapre need two input chardev and one output chardev:
      primary_in=chardev1-id (source: primary send packet)
      secondary_in=chardev2-id (source: secondary send packet)
      outdev=chardev3-id
      
      usage:
      
      primary:
      -netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
      -device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
      -chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait
      -chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait
      -chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait
      -chardev socket,id=compare0-0,host=3.3.3.3,port=9001
      -chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
      -chardev socket,id=compare_out0,host=3.3.3.3,port=9005
      -object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
      -object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
      -object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
      -object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0
      
      secondary:
      -netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
      -device e1000,netdev=hn0,mac=52:a4:00:12:78:66
      -chardev socket,id=red0,host=3.3.3.3,port=9003
      -chardev socket,id=red1,host=3.3.3.3,port=9004
      -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
      -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
      Signed-off-by: NZhang Chen <zhangchen.fnst@cn.fujitsu.com>
      Signed-off-by: NLi Zhijian <lizhijian@cn.fujitsu.com>
      Signed-off-by: NWen Congyang <wency@cn.fujitsu.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      7dce4e6f
    • S
      net: hmp_host_net_remove: Del the -net option of the removed host_net · a4543b1b
      Shmulik Ladkani 提交于
      Upon hmp_host_net_remove(), the appropriate -net client is deleted
      (according to the given vlan_id and device id), as well as the
      corresponsing hub port.
      
      However, the relevant '-net' option that was added by former
      hmp_host_net_add() call is still present in "net" options group.
      
      This makes the following legit HMP sequence erroneous:
      
      (qemu) host_net_add tap id=n1,ifname=tap1,script=no,downscript=no,vlan=1
      (qemu) host_net_remove 1 n1
      (qemu) host_net_add tap id=n1,ifname=tap1,script=no,downscript=no,vlan=1
      Duplicate ID 'n1' for net
      
      Fix, by deleting the stored '-net' option associated with the given
      device id.
      Signed-off-by: NShmulik Ladkani <shmulik.ladkani@ravellosystems.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      a4543b1b
  10. 14 9月, 2016 2 次提交
  11. 30 8月, 2016 1 次提交
  12. 22 8月, 2016 1 次提交
    • M
      slirp: fix segv when init failed · 67f3280c
      Marc-André Lureau 提交于
      Since commit f6c2e66a, slirp uses an exit notifier to call
      slirp_smb_cleanup. However, if init() failed, the notifier isn't added,
      and removing it will fail:
      
      ==18447== Invalid write of size 8
      ==18447==    at 0x7EF2B5: notifier_remove (notify.c:32)
      ==18447==    by 0x48E80C: qemu_remove_exit_notifier (vl.c:2661)
      ==18447==    by 0x6A2187: net_slirp_cleanup (slirp.c:134)
      ==18447==    by 0x69419D: qemu_cleanup_net_client (net.c:338)
      ==18447==    by 0x69445B: qemu_del_net_client (net.c:401)
      ==18447==    by 0x6A2B81: net_slirp_init (slirp.c:366)
      ==18447==    by 0x6A4241: net_init_slirp (slirp.c:865)
      ==18447==    by 0x695C6D: net_client_init1 (net.c:1051)
      ==18447==    by 0x695F6E: net_client_init (net.c:1108)
      ==18447==    by 0x696DBA: net_init_netdev (net.c:1498)
      ==18447==    by 0x7F1F99: qemu_opts_foreach (qemu-option.c:1116)
      ==18447==    by 0x696E60: net_init_clients (net.c:1516)
      ==18447==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
      Signed-off-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      67f3280c
  13. 18 8月, 2016 1 次提交
  14. 12 8月, 2016 1 次提交
  15. 29 7月, 2016 5 次提交
  16. 20 7月, 2016 1 次提交