All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
@ 2013-06-20 13:08 Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 01/21] range: add Range structure Michael S. Tsirkin
                   ` (20 more replies)
  0 siblings, 21 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:08 UTC (permalink / raw)
  To: qemu-devel, Anthony Liguori
  Cc: peter.maydell, drjones, stefano.stabellini, haoyu.zhang,
	Paul.Durrant, akong, lersek, david

From: Michael S. Tsirkin <mst@redhat.com>

The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:

  target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)

are available in the git repository at:

  git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony

for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:

  pci: Fold host_buses list into PCIHostState functionality (2013-06-19 18:35:05 +0300)

----------------------------------------------------------------
pci,net,misc enhancements

This includes some pci and net-related enhancements:

Better support for systems with multiple PCI root buses
A new management interface for access to rx filter in NICs
KVM Speedup for MSI updates on kvm
FW cfg interface for more robust pci programming in BIOS
Minor fixes/cleanups for fw cfg and cross-version migration -
    because of dependencies with other patches

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Amos Kong (1):
      net: add support of mac-programming over macvtap in QEMU side

Andrew Jones (1):
      e1000: cleanup process_tx_desc

David Gibson (10):
      pci: Cleanup configuration for pci-hotplug.c
      pci: Move pci_read_devaddr to pci-hotplug-old.c
      pci: Abolish pci_find_root_bus()
      pci: Use helper to find device's root bus in pci_find_domain()
      pci: Replace pci_find_domain() with more general pci_root_bus_path()
      pci: Add root bus argument to pci_get_bus_devfn()
      pci: Add root bus parameter to pci_nic_init()
      pci: Simpler implementation of primary PCI bus
      pci: Remove domain from PCIHostBus
      pci: Fold host_buses list into PCIHostState functionality

Michael S. Tsirkin (9):
      range: add Range structure
      pci: store PCI hole ranges in guestinfo structure
      pc: pass PCI hole ranges to Guests
      pc_piix: cleanup init compat handling
      kvm: zero-initialize KVM_SET_GSI_ROUTING input
      kvm: skip system call when msi route is unchanged
      MAINTAINERS: s/Marcelo/Paolo/
      pvpanic: initialization cleanup
      pvpanic: fix fwcfg for big endian hosts

 MAINTAINERS                                 |   2 +-
 QMP/qmp-events.txt                          |  17 ++++
 default-configs/i386-softmmu.mak            |   3 +-
 default-configs/ppc64-softmmu.mak           |   2 -
 default-configs/x86_64-softmmu.mak          |   3 +-
 hmp-commands.hx                             |   4 +-
 hw/alpha/dp264.c                            |   2 +-
 hw/arm/realview.c                           |   6 +-
 hw/arm/versatilepb.c                        |   2 +-
 hw/i386/pc.c                                |  74 ++++++++++++++-
 hw/i386/pc_piix.c                           |  40 +++++---
 hw/i386/pc_q35.c                            |  18 +++-
 hw/mips/mips_fulong2e.c                     |   6 +-
 hw/mips/mips_malta.c                        |   6 +-
 hw/misc/pvpanic.c                           |  31 ++++---
 hw/net/e1000.c                              |  18 ++--
 hw/net/virtio-net.c                         | 111 ++++++++++++++++++++++
 hw/pci-host/piix.c                          |   9 ++
 hw/pci-host/q35.c                           |  17 ++++
 hw/pci/Makefile.objs                        |   2 +-
 hw/pci/{pci-hotplug.c => pci-hotplug-old.c} |  75 ++++++++++++---
 hw/pci/pci.c                                | 137 ++++++++++++++--------------
 hw/pci/pci_host.c                           |   1 +
 hw/pci/pcie_aer.c                           |   9 +-
 hw/ppc/e500.c                               |   2 +-
 hw/ppc/mac_newworld.c                       |   2 +-
 hw/ppc/mac_oldworld.c                       |   2 +-
 hw/ppc/ppc440_bamboo.c                      |   2 +-
 hw/ppc/prep.c                               |   2 +-
 hw/ppc/spapr.c                              |   2 +-
 hw/ppc/spapr_pci.c                          |  10 ++
 hw/sh4/r2d.c                                |   5 +-
 hw/sparc64/sun4u.c                          |   2 +-
 include/hw/i386/pc.h                        |  22 ++++-
 include/hw/pci-host/q35.h                   |   2 +
 include/hw/pci/pci.h                        |  17 ++--
 include/hw/pci/pci_host.h                   |  12 +++
 include/monitor/monitor.h                   |   1 +
 include/net/net.h                           |   3 +
 include/qemu/range.h                        |  16 ++++
 include/qemu/typedefs.h                     |   1 +
 kvm-all.c                                   |  23 +++--
 monitor.c                                   |   1 +
 net/net.c                                   |  47 ++++++++++
 qapi-schema.json                            |  75 +++++++++++++++
 qmp-commands.hx                             |  63 +++++++++++++
 46 files changed, 733 insertions(+), 174 deletions(-)
 rename hw/pci/{pci-hotplug.c => pci-hotplug-old.c} (78%)

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

* [Qemu-devel] [PULL 01/21] range: add Range structure
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
@ 2013-06-20 13:08 ` Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Paolo Bonzini

Sometimes we need to pass ranges around, add a
handy structure for this purpose.

Note: memory.c defines its own concept of AddrRange structure for
working with 128 addresses.  It's necessary there for doing range math.
This is not needed for most users: struct Range is
much simpler, and is only used for passing the range around.

Cc: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/qemu/range.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/qemu/range.h b/include/qemu/range.h
index 3502372..b76cc0d 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -1,6 +1,22 @@
 #ifndef QEMU_RANGE_H
 #define QEMU_RANGE_H
 
+#include <inttypes.h>
+
+/*
+ * Operations on 64 bit address ranges.
+ * Notes:
+ *   - ranges must not wrap around 0, but can include the last byte ~0x0LL.
+ *   - this can not represent a full 0 to ~0x0LL range.
+ */
+
+/* A structure representing a range of addresses. */
+struct Range {
+    uint64_t begin; /* First byte of the range, or 0 if empty. */
+    uint64_t end;   /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */
+};
+typedef struct Range Range;
+
 /* Get last byte of a range from offset + length.
  * Undefined for ranges that wrap around 0. */
 static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
-- 
MST

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

* [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 01/21] range: add Range structure Michael S. Tsirkin
@ 2013-06-20 13:08 ` Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 04/21] pc_piix: cleanup init compat handling Michael S. Tsirkin
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:08 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Anthony Liguori, =?UTF-8?q?Andreas=20F=C3=A4rber?=,
	Eduardo Habkost, Igor Mammedov

Guest currently has to jump through lots of hoops to guess the PCI hole
ranges.  It's fragile, and makes us change BIOS each time we add a new
chipset.  Let's report the window in a ROM file, to make BIOS do exactly
what QEMU intends.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/pc.c         | 26 ++++++++++++++++++++++++++
 hw/i386/pc_piix.c    | 16 +++++++++++++++-
 hw/i386/pc_q35.c     | 12 ++++++++++--
 include/hw/i386/pc.h |  1 +
 4 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c685ee8..e1ed760 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -990,6 +990,31 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)
     }
 }
 
+/* pci-info ROM file. Little endian format */
+typedef struct PcRomPciInfo {
+    uint64_t w32_min;
+    uint64_t w32_max;
+    uint64_t w64_min;
+    uint64_t w64_max;
+} PcRomPciInfo;
+
+static void pc_fw_cfg_guest_info(PcGuestInfo *guest_info)
+{
+    PcRomPciInfo *info;
+    if (!guest_info->has_pci_info) {
+        return;
+    }
+
+    info = g_malloc(sizeof *info);
+    info->w32_min = cpu_to_le64(guest_info->pci_info.w32.begin);
+    info->w32_max = cpu_to_le64(guest_info->pci_info.w32.end);
+    info->w64_min = cpu_to_le64(guest_info->pci_info.w64.begin);
+    info->w64_max = cpu_to_le64(guest_info->pci_info.w64.end);
+    /* Pass PCI hole info to guest via a side channel.
+     * Required so guest PCI enumeration does the right thing. */
+    fw_cfg_add_file(guest_info->fw_cfg, "etc/pci-info", info, sizeof *info);
+}
+
 typedef struct PcGuestInfoState {
     PcGuestInfo info;
     Notifier machine_done;
@@ -1001,6 +1026,7 @@ void pc_guest_info_machine_done(Notifier *notifier, void *data)
     PcGuestInfoState *guest_info_state = container_of(notifier,
                                                       PcGuestInfoState,
                                                       machine_done);
+    pc_fw_cfg_guest_info(&guest_info_state->info);
 }
 
 PcGuestInfo *pc_guest_info_init(ram_addr_t below_4g_mem_size,
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a70a0d9..d87da95 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -57,6 +57,7 @@ static const int ide_iobase2[MAX_IDE_BUS] = { 0x3f6, 0x376 };
 static const int ide_irq[MAX_IDE_BUS] = { 14, 15 };
 
 static bool has_pvpanic = true;
+static bool has_pci_info = true;
 
 /* PC hardware initialisation */
 static void pc_init1(MemoryRegion *system_memory,
@@ -121,6 +122,7 @@ static void pc_init1(MemoryRegion *system_memory,
     }
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
+    guest_info->has_pci_info = has_pci_info;
 
     /* Set PCI window size the way seabios has always done it. */
     /* Power of 2 so bios can cover it with a single MTRR */
@@ -258,8 +260,15 @@ static void pc_init_pci(QEMUMachineInitArgs *args)
              initrd_filename, cpu_model, 1, 1);
 }
 
+static void pc_init_pci_1_5(QEMUMachineInitArgs *args)
+{
+    has_pci_info = false;
+    pc_init_pci(args);
+}
+
 static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
 {
+    has_pci_info = false;
     has_pvpanic = false;
     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
     pc_init_pci(args);
@@ -267,6 +276,7 @@ static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
 
 static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
 {
+    has_pci_info = false;
     enable_compat_apic_id_mode();
     has_pvpanic = false;
     pc_init_pci(args);
@@ -275,6 +285,7 @@ static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
 /* PC machine init function for pc-1.1 to pc-1.2 */
 static void pc_init_pci_1_2(QEMUMachineInitArgs *args)
 {
+    has_pci_info = false;
     disable_kvm_pv_eoi();
     enable_compat_apic_id_mode();
     has_pvpanic = false;
@@ -284,6 +295,7 @@ static void pc_init_pci_1_2(QEMUMachineInitArgs *args)
 /* PC machine init function for pc-0.14 to pc-1.0 */
 static void pc_init_pci_1_0(QEMUMachineInitArgs *args)
 {
+    has_pci_info = false;
     disable_kvm_pv_eoi();
     enable_compat_apic_id_mode();
     has_pvpanic = false;
@@ -300,6 +312,7 @@ static void pc_init_pci_no_kvmclock(QEMUMachineInitArgs *args)
     const char *initrd_filename = args->initrd_filename;
     const char *boot_device = args->boot_device;
     has_pvpanic = false;
+    has_pci_info = false;
     disable_kvm_pv_eoi();
     enable_compat_apic_id_mode();
     pc_init1(get_system_memory(),
@@ -318,6 +331,7 @@ static void pc_init_isa(QEMUMachineInitArgs *args)
     const char *initrd_filename = args->initrd_filename;
     const char *boot_device = args->boot_device;
     has_pvpanic = false;
+    has_pci_info = false;
     if (cpu_model == NULL)
         cpu_model = "486";
     disable_kvm_pv_eoi();
@@ -353,7 +367,7 @@ static QEMUMachine pc_i440fx_machine_v1_6 = {
 static QEMUMachine pc_i440fx_machine_v1_5 = {
     .name = "pc-i440fx-1.5",
     .desc = "Standard PC (i440FX + PIIX, 1996)",
-    .init = pc_init_pci,
+    .init = pc_init_pci_1_5,
     .hot_add_cpu = pc_hot_add_cpu,
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a13acf2..5b92160 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -47,6 +47,7 @@
 #define MAX_SATA_PORTS     6
 
 static bool has_pvpanic = true;
+static bool has_pci_info = true;
 
 /* PC hardware initialisation */
 static void pc_q35_init(QEMUMachineInitArgs *args)
@@ -107,6 +108,7 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
     }
 
     guest_info = pc_guest_info_init(below_4g_mem_size, above_4g_mem_size);
+    guest_info->has_pci_info = has_pci_info;
 
     /* allocate ram and load rom/bios */
     if (!xen_enabled()) {
@@ -212,11 +214,17 @@ static void pc_q35_init(QEMUMachineInitArgs *args)
     }
 }
 
+static void pc_q35_init_1_5(QEMUMachineInitArgs *args)
+{
+    has_pci_info = false;
+    pc_q35_init(args);
+}
+
 static void pc_q35_init_1_4(QEMUMachineInitArgs *args)
 {
     has_pvpanic = false;
     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
-    pc_q35_init(args);
+    pc_q35_init_1_5(args);
 }
 
 static QEMUMachine pc_q35_machine_v1_6 = {
@@ -232,7 +240,7 @@ static QEMUMachine pc_q35_machine_v1_6 = {
 static QEMUMachine pc_q35_machine_v1_5 = {
     .name = "pc-q35-1.5",
     .desc = "Standard PC (Q35 + ICH9, 2009)",
-    .init = pc_q35_init,
+    .init = pc_q35_init_1_5,
     .hot_add_cpu = pc_hot_add_cpu,
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 6cb06fe..ba9ba1a 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -20,6 +20,7 @@ typedef struct PcPciInfo {
 
 struct PcGuestInfo {
     PcPciInfo pci_info;
+    bool has_pci_info;
     FWCfgState *fw_cfg;
 };
 
-- 
MST

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

* [Qemu-devel] [PULL 04/21] pc_piix: cleanup init compat handling
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 01/21] range: add Range structure Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
@ 2013-06-20 13:08 ` Michael S. Tsirkin
  2013-06-20 13:10 ` [Qemu-devel] [PULL 05/21] e1000: cleanup process_tx_desc Michael S. Tsirkin
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Anthony Liguori

Make sure 1.4 calls 1.5, 1.3 calls 1.4 etc.
This way it's enough to add enough new compat hook
in a single place in piix.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/pc_piix.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index d87da95..234424a 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -268,38 +268,28 @@ static void pc_init_pci_1_5(QEMUMachineInitArgs *args)
 
 static void pc_init_pci_1_4(QEMUMachineInitArgs *args)
 {
-    has_pci_info = false;
     has_pvpanic = false;
     x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
-    pc_init_pci(args);
+    pc_init_pci_1_5(args);
 }
 
 static void pc_init_pci_1_3(QEMUMachineInitArgs *args)
 {
-    has_pci_info = false;
     enable_compat_apic_id_mode();
-    has_pvpanic = false;
-    pc_init_pci(args);
+    pc_init_pci_1_4(args);
 }
 
 /* PC machine init function for pc-1.1 to pc-1.2 */
 static void pc_init_pci_1_2(QEMUMachineInitArgs *args)
 {
-    has_pci_info = false;
     disable_kvm_pv_eoi();
-    enable_compat_apic_id_mode();
-    has_pvpanic = false;
-    pc_init_pci(args);
+    pc_init_pci_1_3(args);
 }
 
 /* PC machine init function for pc-0.14 to pc-1.0 */
 static void pc_init_pci_1_0(QEMUMachineInitArgs *args)
 {
-    has_pci_info = false;
-    disable_kvm_pv_eoi();
-    enable_compat_apic_id_mode();
-    has_pvpanic = false;
-    pc_init_pci(args);
+    pc_init_pci_1_2(args);
 }
 
 /* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
-- 
MST

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

* [Qemu-devel] [PULL 05/21] e1000: cleanup process_tx_desc
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2013-06-20 13:08 ` [Qemu-devel] [PULL 04/21] pc_piix: cleanup init compat handling Michael S. Tsirkin
@ 2013-06-20 13:10 ` Michael S. Tsirkin
  2013-06-20 13:10   ` [Qemu-devel] " Michael S. Tsirkin
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jason Wang, Paolo Bonzini, Andrew Jones, Anthony Liguori,
	Stefan Hajnoczi

From: Andrew Jones <drjones@redhat.com>

Coverity complains about two overruns in process_tx_desc(). The
complaints are false positives, but we might as well eliminate
them. The problem is that "hdr" is defined as an unsigned int,
but then used to offset an array of size 65536, and another of
size 256 bytes. hdr will actually never be greater than 255
though, as it's assigned only once and to the value of
tp->hdr_len, which is an uint8_t. This patch simply gets rid of
hdr, replacing it with tp->hdr_len, which makes it consistent
with all other tp member use in the function.

v2:
 - also cleanup coding style issues in the touched lines

Signed-off-by: Andrew Jones <drjones@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/net/e1000.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index e6f46f0..620f947 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -556,7 +556,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
     uint32_t txd_lower = le32_to_cpu(dp->lower.data);
     uint32_t dtype = txd_lower & (E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D);
     unsigned int split_size = txd_lower & 0xffff, bytes, sz, op;
-    unsigned int msh = 0xfffff, hdr = 0;
+    unsigned int msh = 0xfffff;
     uint64_t addr;
     struct e1000_context_desc *xp = (struct e1000_context_desc *)dp;
     struct e1000_tx *tp = &s->tx;
@@ -603,8 +603,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
         
     addr = le64_to_cpu(dp->buffer_addr);
     if (tp->tse && tp->cptse) {
-        hdr = tp->hdr_len;
-        msh = hdr + tp->mss;
+        msh = tp->hdr_len + tp->mss;
         do {
             bytes = split_size;
             if (tp->size + bytes > msh)
@@ -612,14 +611,16 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
 
             bytes = MIN(sizeof(tp->data) - tp->size, bytes);
             pci_dma_read(&s->dev, addr, tp->data + tp->size, bytes);
-            if ((sz = tp->size + bytes) >= hdr && tp->size < hdr)
-                memmove(tp->header, tp->data, hdr);
+            sz = tp->size + bytes;
+            if (sz >= tp->hdr_len && tp->size < tp->hdr_len) {
+                memmove(tp->header, tp->data, tp->hdr_len);
+            }
             tp->size = sz;
             addr += bytes;
             if (sz == msh) {
                 xmit_seg(s);
-                memmove(tp->data, tp->header, hdr);
-                tp->size = hdr;
+                memmove(tp->data, tp->header, tp->hdr_len);
+                tp->size = tp->hdr_len;
             }
         } while (split_size -= bytes);
     } else if (!tp->tse && tp->cptse) {
@@ -633,8 +634,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp)
 
     if (!(txd_lower & E1000_TXD_CMD_EOP))
         return;
-    if (!(tp->tse && tp->cptse && tp->size < hdr))
+    if (!(tp->tse && tp->cptse && tp->size < tp->hdr_len)) {
         xmit_seg(s);
+    }
     tp->tso_frames = 0;
     tp->sum_needed = 0;
     tp->vlan_needed = 0;
-- 
MST

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

* [PULL 06/21] kvm: zero-initialize KVM_SET_GSI_ROUTING input
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
@ 2013-06-20 13:10   ` Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
                     ` (19 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gleb Natapov, Paolo Bonzini, kvm

kvm_add_routing_entry makes an attempt to
zero-initialize any new routing entry.
However, it fails to initialize padding
within the u field of the structure
kvm_irq_routing_entry.

Other functions like kvm_irqchip_update_msi_route
also fail to initialize the padding field in
kvm_irq_routing_entry.

While mostly harmless, this would prevent us from
reusing these fields for something useful in
the future.

It's better to just make sure all input is initialized.

Once it is, we can also drop complex field by field assignment and just
do the simple *a = *b to update a route entry.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 kvm-all.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 405480e..f119ce1 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1006,11 +1006,8 @@ static void kvm_add_routing_entry(KVMState *s,
     }
     n = s->irq_routes->nr++;
     new = &s->irq_routes->entries[n];
-    memset(new, 0, sizeof(*new));
-    new->gsi = entry->gsi;
-    new->type = entry->type;
-    new->flags = entry->flags;
-    new->u = entry->u;
+
+    *new = *entry;
 
     set_gsi(s, entry->gsi);
 
@@ -1029,9 +1026,7 @@ static int kvm_update_routing_entry(KVMState *s,
             continue;
         }
 
-        entry->type = new_entry->type;
-        entry->flags = new_entry->flags;
-        entry->u = new_entry->u;
+        *entry = *new_entry;
 
         kvm_irqchip_commit_routes(s);
 
@@ -1043,7 +1038,7 @@ static int kvm_update_routing_entry(KVMState *s,
 
 void kvm_irqchip_add_irq_route(KVMState *s, int irq, int irqchip, int pin)
 {
-    struct kvm_irq_routing_entry e;
+    struct kvm_irq_routing_entry e = {};
 
     assert(pin < s->gsi_count);
 
@@ -1156,7 +1151,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
             return virq;
         }
 
-        route = g_malloc(sizeof(KVMMSIRoute));
+        route = g_malloc0(sizeof(KVMMSIRoute));
         route->kroute.gsi = virq;
         route->kroute.type = KVM_IRQ_ROUTING_MSI;
         route->kroute.flags = 0;
@@ -1177,7 +1172,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
 
 int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
 {
-    struct kvm_irq_routing_entry kroute;
+    struct kvm_irq_routing_entry kroute = {};
     int virq;
 
     if (!kvm_gsi_routing_enabled()) {
@@ -1203,7 +1198,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
 
 int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
 {
-    struct kvm_irq_routing_entry kroute;
+    struct kvm_irq_routing_entry kroute = {};
 
     if (!kvm_irqchip_in_kernel()) {
         return -ENOSYS;
-- 
MST


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

* [Qemu-devel] [PULL 06/21] kvm: zero-initialize KVM_SET_GSI_ROUTING input
@ 2013-06-20 13:10   ` Michael S. Tsirkin
  0 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm, Gleb Natapov

kvm_add_routing_entry makes an attempt to
zero-initialize any new routing entry.
However, it fails to initialize padding
within the u field of the structure
kvm_irq_routing_entry.

Other functions like kvm_irqchip_update_msi_route
also fail to initialize the padding field in
kvm_irq_routing_entry.

While mostly harmless, this would prevent us from
reusing these fields for something useful in
the future.

It's better to just make sure all input is initialized.

Once it is, we can also drop complex field by field assignment and just
do the simple *a = *b to update a route entry.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 kvm-all.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/kvm-all.c b/kvm-all.c
index 405480e..f119ce1 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1006,11 +1006,8 @@ static void kvm_add_routing_entry(KVMState *s,
     }
     n = s->irq_routes->nr++;
     new = &s->irq_routes->entries[n];
-    memset(new, 0, sizeof(*new));
-    new->gsi = entry->gsi;
-    new->type = entry->type;
-    new->flags = entry->flags;
-    new->u = entry->u;
+
+    *new = *entry;
 
     set_gsi(s, entry->gsi);
 
@@ -1029,9 +1026,7 @@ static int kvm_update_routing_entry(KVMState *s,
             continue;
         }
 
-        entry->type = new_entry->type;
-        entry->flags = new_entry->flags;
-        entry->u = new_entry->u;
+        *entry = *new_entry;
 
         kvm_irqchip_commit_routes(s);
 
@@ -1043,7 +1038,7 @@ static int kvm_update_routing_entry(KVMState *s,
 
 void kvm_irqchip_add_irq_route(KVMState *s, int irq, int irqchip, int pin)
 {
-    struct kvm_irq_routing_entry e;
+    struct kvm_irq_routing_entry e = {};
 
     assert(pin < s->gsi_count);
 
@@ -1156,7 +1151,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
             return virq;
         }
 
-        route = g_malloc(sizeof(KVMMSIRoute));
+        route = g_malloc0(sizeof(KVMMSIRoute));
         route->kroute.gsi = virq;
         route->kroute.type = KVM_IRQ_ROUTING_MSI;
         route->kroute.flags = 0;
@@ -1177,7 +1172,7 @@ int kvm_irqchip_send_msi(KVMState *s, MSIMessage msg)
 
 int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
 {
-    struct kvm_irq_routing_entry kroute;
+    struct kvm_irq_routing_entry kroute = {};
     int virq;
 
     if (!kvm_gsi_routing_enabled()) {
@@ -1203,7 +1198,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
 
 int kvm_irqchip_update_msi_route(KVMState *s, int virq, MSIMessage msg)
 {
-    struct kvm_irq_routing_entry kroute;
+    struct kvm_irq_routing_entry kroute = {};
 
     if (!kvm_irqchip_in_kernel()) {
         return -ENOSYS;
-- 
MST

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

* [PULL 07/21] kvm: skip system call when msi route is unchanged
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
@ 2013-06-20 13:10   ` Michael S. Tsirkin
  2013-06-20 13:08 ` [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
                     ` (19 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gleb Natapov, Paolo Bonzini, kvm

Some guests do a large number of mask/unmask
calls which currently trigger expensive route update
system calls.
Detect that route in unchanged and skip the system call.

Reported-by: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 kvm-all.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kvm-all.c b/kvm-all.c
index f119ce1..891722b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1026,6 +1026,10 @@ static int kvm_update_routing_entry(KVMState *s,
             continue;
         }
 
+        if(!memcmp(entry, new_entry, sizeof *entry)) {
+            return 0;
+        }
+
         *entry = *new_entry;
 
         kvm_irqchip_commit_routes(s);
-- 
MST


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

* [Qemu-devel] [PULL 07/21] kvm: skip system call when msi route is unchanged
@ 2013-06-20 13:10   ` Michael S. Tsirkin
  0 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, kvm, Gleb Natapov

Some guests do a large number of mask/unmask
calls which currently trigger expensive route update
system calls.
Detect that route in unchanged and skip the system call.

Reported-by: "Zhanghaoyu (A)" <haoyu.zhang@huawei.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 kvm-all.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kvm-all.c b/kvm-all.c
index f119ce1..891722b 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1026,6 +1026,10 @@ static int kvm_update_routing_entry(KVMState *s,
             continue;
         }
 
+        if(!memcmp(entry, new_entry, sizeof *entry)) {
+            return 0;
+        }
+
         *entry = *new_entry;
 
         kvm_irqchip_commit_routes(s);
-- 
MST

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

* [Qemu-devel] [PULL 08/21] MAINTAINERS: s/Marcelo/Paolo/
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2013-06-20 13:10   ` [Qemu-devel] " Michael S. Tsirkin
@ 2013-06-20 13:10 ` Michael S. Tsirkin
  2013-06-20 13:10 ` [Qemu-devel] [PULL 09/21] pvpanic: initialization cleanup Michael S. Tsirkin
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter A. G. Crosthwaite, Peter Maydell,
	=?UTF-8?q?Andreas=20F=C3=A4rber?=,
	Stefan Hajnoczi, Alexander Graf

Marcelo doesn't maintain kvm anymore,
Paolo is taking over the job.
Update MAINTAINERS to stop flooding Marcelo with mail.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3412b07..f329406 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -155,7 +155,7 @@ Guest CPU Cores (KVM):
 
 Overall
 M: Gleb Natapov <gleb@redhat.com>
-M: Marcelo Tosatti <mtosatti@redhat.com>
+M: Paolo Bonzini <pbonzini@redhat.com>
 L: kvm@vger.kernel.org
 S: Supported
 F: kvm-*
-- 
MST

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

* [Qemu-devel] [PULL 09/21] pvpanic: initialization cleanup
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (6 preceding siblings ...)
  2013-06-20 13:10 ` [Qemu-devel] [PULL 08/21] MAINTAINERS: s/Marcelo/Paolo/ Michael S. Tsirkin
@ 2013-06-20 13:10 ` Michael S. Tsirkin
  2013-06-20 13:10 ` [Qemu-devel] [PULL 10/21] pvpanic: fix fwcfg for big endian hosts Michael S. Tsirkin
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Eduardo Habkost, Stefano Stabellini, Hu Tao,
	Markus Armbruster, Paul Durrant, Paolo Bonzini, Laszlo Ersek,
	=?UTF-8?q?Andreas=20F=C3=A4rber?=

Avoid use of static variables: PC systems
initialize pvpanic device through pvpanic_init,
so we can simply create the fw_cfg file at that point.
This also makes it possible to skip device
creation completely if fw_cfg is not there, e.g. for xen -
so the ports it reserves are not discoverable by guests.

Also, make pvpanic_init void since callers ignore return
status anyway.

Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Paul Durrant <Paul.Durrant@citrix.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c    | 30 ++++++++++++++++--------------
 include/hw/i386/pc.h |  2 +-
 2 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 060099b..83ed226 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -97,26 +97,28 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 {
     ISADevice *d = ISA_DEVICE(dev);
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
-    static bool port_configured;
-    FWCfgState *fw_cfg;
 
     isa_register_ioport(d, &s->io, s->ioport);
+}
 
-    if (!port_configured) {
-        fw_cfg = fw_cfg_find();
-        if (fw_cfg) {
-            fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
-                            g_memdup(&s->ioport, sizeof(s->ioport)),
-                            sizeof(s->ioport));
-            port_configured = true;
-        }
-    }
+static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg)
+{
+    PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+
+    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
+                    g_memdup(&s->ioport, sizeof(s->ioport)),
+                    sizeof(s->ioport));
 }
 
-int pvpanic_init(ISABus *bus)
+void pvpanic_init(ISABus *bus)
 {
-    isa_create_simple(bus, TYPE_ISA_PVPANIC_DEVICE);
-    return 0;
+    ISADevice *dev;
+    FWCfgState *fw_cfg = fw_cfg_find();
+    if (!fw_cfg) {
+        return;
+    }
+    dev = isa_create_simple (bus, TYPE_ISA_PVPANIC_DEVICE);
+    pvpanic_fw_cfg(dev, fw_cfg);
 }
 
 static Property pvpanic_isa_properties[] = {
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index ba9ba1a..458eded 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -196,7 +196,7 @@ static inline bool isa_ne2000_init(ISABus *bus, int base, int irq, NICInfo *nd)
 void pc_system_firmware_init(MemoryRegion *rom_memory);
 
 /* pvpanic.c */
-int pvpanic_init(ISABus *bus);
+void pvpanic_init(ISABus *bus);
 
 /* e820 types */
 #define E820_RAM        1
-- 
MST

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

* [Qemu-devel] [PULL 10/21] pvpanic: fix fwcfg for big endian hosts
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (7 preceding siblings ...)
  2013-06-20 13:10 ` [Qemu-devel] [PULL 09/21] pvpanic: initialization cleanup Michael S. Tsirkin
@ 2013-06-20 13:10 ` Michael S. Tsirkin
  2013-06-20 13:10 ` [Qemu-devel] [PULL 11/21] net: add support of mac-programming over macvtap in QEMU side Michael S. Tsirkin
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hu Tao, Anthony Liguori, Markus Armbruster

Convert port number to little endian when
exposing it in fw cfg.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/misc/pvpanic.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
index 83ed226..792d8e4 100644
--- a/hw/misc/pvpanic.c
+++ b/hw/misc/pvpanic.c
@@ -104,10 +104,11 @@ static void pvpanic_isa_realizefn(DeviceState *dev, Error **errp)
 static void pvpanic_fw_cfg(ISADevice *dev, FWCfgState *fw_cfg)
 {
     PVPanicState *s = ISA_PVPANIC_DEVICE(dev);
+    uint16_t *pvpanic_port = g_malloc(sizeof(*pvpanic_port));
+    *pvpanic_port = cpu_to_le16(s->ioport);
 
-    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
-                    g_memdup(&s->ioport, sizeof(s->ioport)),
-                    sizeof(s->ioport));
+    fw_cfg_add_file(fw_cfg, "etc/pvpanic-port", pvpanic_port,
+                    sizeof(*pvpanic_port));
 }
 
 void pvpanic_init(ISABus *bus)
-- 
MST

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

* [Qemu-devel] [PULL 11/21] net: add support of mac-programming over macvtap in QEMU side
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (8 preceding siblings ...)
  2013-06-20 13:10 ` [Qemu-devel] [PULL 10/21] pvpanic: fix fwcfg for big endian hosts Michael S. Tsirkin
@ 2013-06-20 13:10 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 13/21] pci: Move pci_read_devaddr to pci-hotplug-old.c Michael S. Tsirkin
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:10 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Anthony Liguori, Laszlo Ersek, Jason Wang,
	Markus Armbruster, Luiz Capitulino, Zhi Yong Wu, Stefan Hajnoczi,
	Paolo Bonzini, Amos Kong

From: Amos Kong <akong@redhat.com>

Currently macvtap based macvlan device is working in promiscuous
mode, we want to implement mac-programming over macvtap through
Libvirt for better performance.

Design:
 QEMU notifies Libvirt when rx-filter config is changed in guest,
 then Libvirt query the rx-filter information by a monitor command,
 and sync the change to macvtap device. Related rx-filter config
 of the nic contains main mac, rx-mode items and vlan table.

This patch adds a QMP event to notify management of rx-filter change,
and adds a monitor command for management to query rx-filter
information.

Test:
 If we repeatedly add/remove vlan, and change macaddr of vlan
 interfaces in guest by a loop script.

Result:
 The events will flood the QMP client(management), management takes
 too much resource to process the events.

 Event_throttle API (set rate to 1 ms) can avoid the events to flood
 QMP client, but it could cause an unexpected delay (~1ms), guests
 guests normally expect rx-filter updates immediately.

 So we use a flag for each nic to avoid events flooding, the event
 is emitted once until the query command is executed. The flag
 implementation could not introduce unexpected delay.

There maybe exist an uncontrollable delay if we let Libvirt do the
real change, guests normally expect rx-filter updates immediately.
But it's another separate issue, we can investigate it when the
work in Libvirt side is done.

Michael S. Tsirkin: tweaked to enable events on start.

Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 QMP/qmp-events.txt        |  17 +++++++
 hw/net/virtio-net.c       | 111 ++++++++++++++++++++++++++++++++++++++++++++++
 include/monitor/monitor.h |   1 +
 include/net/net.h         |   3 ++
 monitor.c                 |   1 +
 net/net.c                 |  47 ++++++++++++++++++++
 qapi-schema.json          |  75 +++++++++++++++++++++++++++++++
 qmp-commands.hx           |  63 ++++++++++++++++++++++++++
 8 files changed, 318 insertions(+)

diff --git a/QMP/qmp-events.txt b/QMP/qmp-events.txt
index 24e804e9..39b6016 100644
--- a/QMP/qmp-events.txt
+++ b/QMP/qmp-events.txt
@@ -172,6 +172,23 @@ Data:
   },
   "timestamp": { "seconds": 1265044230, "microseconds": 450486 } }
 
+NIC_RX_FILTER_CHANGED
+-----------------
+
+The event is emitted once until the query command is executed,
+the first event will always be emitted.
+
+Data:
+
+- "name": net client name (json-string)
+- "path": device path (json-string)
+
+{ "event": "NIC_RX_FILTER_CHANGED",
+  "data": { "name": "vnet0",
+            "path": "/machine/peripheral/vnet0/virtio-backend" },
+  "timestamp": { "seconds": 1368697518, "microseconds": 326866 } }
+}
+
 RESET
 -----
 
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 1ea9556..a8e4101 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -21,6 +21,8 @@
 #include "hw/virtio/virtio-net.h"
 #include "net/vhost_net.h"
 #include "hw/virtio/virtio-bus.h"
+#include "qapi/qmp/qjson.h"
+#include "monitor/monitor.h"
 
 #define VIRTIO_NET_VM_VERSION    11
 
@@ -192,6 +194,100 @@ static void virtio_net_set_link_status(NetClientState *nc)
     virtio_net_set_status(vdev, vdev->status);
 }
 
+static void rxfilter_notify(NetClientState *nc)
+{
+    QObject *event_data;
+    VirtIONet *n = qemu_get_nic_opaque(nc);
+
+    if (nc->rxfilter_notify_enabled) {
+        event_data = qobject_from_jsonf("{ 'name': %s, 'path': %s }",
+                           n->netclient_name,
+                           object_get_canonical_path(OBJECT(n->qdev)));
+        monitor_protocol_event(QEVENT_NIC_RX_FILTER_CHANGED, event_data);
+        qobject_decref(event_data);
+
+        /* disable event notification to avoid events flooding */
+        nc->rxfilter_notify_enabled = 0;
+    }
+}
+
+static char *mac_strdup_printf(const uint8_t *mac)
+{
+    return g_strdup_printf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", mac[0],
+                            mac[1], mac[2], mac[3], mac[4], mac[5]);
+}
+
+static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
+{
+    VirtIONet *n = qemu_get_nic_opaque(nc);
+    RxFilterInfo *info;
+    strList *str_list = NULL;
+    strList *entry;
+    intList *int_list = NULL;
+    intList *int_entry;
+    int i, j;
+
+    info = g_malloc0(sizeof(*info));
+    info->name = g_strdup(nc->name);
+    info->promiscuous = n->promisc;
+
+    if (n->nouni) {
+        info->unicast = RX_STATE_NONE;
+    } else if (n->alluni) {
+        info->unicast = RX_STATE_ALL;
+    } else {
+        info->unicast = RX_STATE_NORMAL;
+    }
+
+    if (n->nomulti) {
+        info->multicast = RX_STATE_NONE;
+    } else if (n->allmulti) {
+        info->multicast = RX_STATE_ALL;
+    } else {
+        info->multicast = RX_STATE_NORMAL;
+    }
+
+    info->broadcast_allowed = n->nobcast;
+    info->multicast_overflow = n->mac_table.multi_overflow;
+    info->unicast_overflow = n->mac_table.uni_overflow;
+
+    info->main_mac = mac_strdup_printf(n->mac);
+
+    for (i = 0; i < n->mac_table.first_multi; i++) {
+        entry = g_malloc0(sizeof(*entry));
+        entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
+        entry->next = str_list;
+        str_list = entry;
+    }
+    info->unicast_table = str_list;
+
+    str_list = NULL;
+    for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {
+        entry = g_malloc0(sizeof(*entry));
+        entry->value = mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
+        entry->next = str_list;
+        str_list = entry;
+    }
+    info->multicast_table = str_list;
+
+    for (i = 0; i < MAX_VLAN >> 5; i++) {
+        for (j = 0; n->vlans[i] && j < 0x1f; j++) {
+            if (n->vlans[i] & (1U << j)) {
+                int_entry = g_malloc0(sizeof(*int_entry));
+                int_entry->value = (i << 5) + j;
+                int_entry->next = int_list;
+                int_list = int_entry;
+            }
+        }
+    }
+    info->vlan_table = int_list;
+
+    /* enable event notification after query */
+    nc->rxfilter_notify_enabled = 1;
+
+    return info;
+}
+
 static void virtio_net_reset(VirtIODevice *vdev)
 {
     VirtIONet *n = VIRTIO_NET(vdev);
@@ -420,6 +516,7 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
 {
     uint8_t on;
     size_t s;
+    NetClientState *nc = qemu_get_queue(n->nic);
 
     s = iov_to_buf(iov, iov_cnt, 0, &on, sizeof(on));
     if (s != sizeof(on)) {
@@ -442,6 +539,8 @@ static int virtio_net_handle_rx_mode(VirtIONet *n, uint8_t cmd,
         return VIRTIO_NET_ERR;
     }
 
+    rxfilter_notify(nc);
+
     return VIRTIO_NET_OK;
 }
 
@@ -487,6 +586,7 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
 {
     struct virtio_net_ctrl_mac mac_data;
     size_t s;
+    NetClientState *nc = qemu_get_queue(n->nic);
 
     if (cmd == VIRTIO_NET_CTRL_MAC_ADDR_SET) {
         if (iov_size(iov, iov_cnt) != sizeof(n->mac)) {
@@ -495,6 +595,8 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
         s = iov_to_buf(iov, iov_cnt, 0, &n->mac, sizeof(n->mac));
         assert(s == sizeof(n->mac));
         qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
+        rxfilter_notify(nc);
+
         return VIRTIO_NET_OK;
     }
 
@@ -559,6 +661,8 @@ static int virtio_net_handle_mac(VirtIONet *n, uint8_t cmd,
         n->mac_table.multi_overflow = 1;
     }
 
+    rxfilter_notify(nc);
+
     return VIRTIO_NET_OK;
 }
 
@@ -567,6 +671,7 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
 {
     uint16_t vid;
     size_t s;
+    NetClientState *nc = qemu_get_queue(n->nic);
 
     s = iov_to_buf(iov, iov_cnt, 0, &vid, sizeof(vid));
     vid = lduw_p(&vid);
@@ -584,6 +689,8 @@ static int virtio_net_handle_vlan_table(VirtIONet *n, uint8_t cmd,
     else
         return VIRTIO_NET_ERR;
 
+    rxfilter_notify(nc);
+
     return VIRTIO_NET_OK;
 }
 
@@ -1312,6 +1419,7 @@ static NetClientInfo net_virtio_info = {
     .receive = virtio_net_receive,
         .cleanup = virtio_net_cleanup,
     .link_status_changed = virtio_net_set_link_status,
+    .query_rx_filter = virtio_net_query_rxfilter,
 };
 
 static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx)
@@ -1373,6 +1481,7 @@ static int virtio_net_device_init(VirtIODevice *vdev)
 
     DeviceState *qdev = DEVICE(vdev);
     VirtIONet *n = VIRTIO_NET(vdev);
+    NetClientState *nc = qemu_get_queue(n->nic);
 
     virtio_init(VIRTIO_DEVICE(n), "virtio-net", VIRTIO_ID_NET,
                                   n->config_size);
@@ -1439,6 +1548,8 @@ static int virtio_net_device_init(VirtIODevice *vdev)
 
     n->vlans = g_malloc0(MAX_VLAN >> 3);
 
+    nc->rxfilter_notify_enabled = 1;
+
     n->qdev = qdev;
     register_savevm(qdev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
                     virtio_net_save, virtio_net_load, n);
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 1a6cfcf..1942cc4 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -41,6 +41,7 @@ typedef enum MonitorEvent {
     QEVENT_BLOCK_JOB_READY,
     QEVENT_DEVICE_DELETED,
     QEVENT_DEVICE_TRAY_MOVED,
+    QEVENT_NIC_RX_FILTER_CHANGED,
     QEVENT_SUSPEND,
     QEVENT_SUSPEND_DISK,
     QEVENT_WAKEUP,
diff --git a/include/net/net.h b/include/net/net.h
index 43d85a1..30e4b04 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -49,6 +49,7 @@ typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);
 typedef void (NetCleanup) (NetClientState *);
 typedef void (LinkStatusChanged)(NetClientState *);
 typedef void (NetClientDestructor)(NetClientState *);
+typedef RxFilterInfo *(QueryRxFilter)(NetClientState *);
 
 typedef struct NetClientInfo {
     NetClientOptionsKind type;
@@ -59,6 +60,7 @@ typedef struct NetClientInfo {
     NetCanReceive *can_receive;
     NetCleanup *cleanup;
     LinkStatusChanged *link_status_changed;
+    QueryRxFilter *query_rx_filter;
     NetPoll *poll;
 } NetClientInfo;
 
@@ -74,6 +76,7 @@ struct NetClientState {
     unsigned receive_disabled : 1;
     NetClientDestructor *destructor;
     unsigned int queue_index;
+    unsigned rxfilter_notify_enabled:1;
 };
 
 typedef struct NICState {
diff --git a/monitor.c b/monitor.c
index 70ae8f5..dd8b694 100644
--- a/monitor.c
+++ b/monitor.c
@@ -490,6 +490,7 @@ static const char *monitor_event_names[] = {
     [QEVENT_BLOCK_JOB_READY] = "BLOCK_JOB_READY",
     [QEVENT_DEVICE_DELETED] = "DEVICE_DELETED",
     [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED",
+    [QEVENT_NIC_RX_FILTER_CHANGED] = "NIC_RX_FILTER_CHANGED",
     [QEVENT_SUSPEND] = "SUSPEND",
     [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK",
     [QEVENT_WAKEUP] = "WAKEUP",
diff --git a/net/net.c b/net/net.c
index 43a74e4..33abffe 100644
--- a/net/net.c
+++ b/net/net.c
@@ -961,6 +961,53 @@ void print_net_client(Monitor *mon, NetClientState *nc)
                    nc->info_str);
 }
 
+RxFilterInfoList *qmp_query_rx_filter(bool has_name, const char *name,
+                                      Error **errp)
+{
+    NetClientState *nc;
+    RxFilterInfoList *filter_list = NULL, *last_entry = NULL;
+
+    QTAILQ_FOREACH(nc, &net_clients, next) {
+        RxFilterInfoList *entry;
+        RxFilterInfo *info;
+
+        /* only query rx-filter information of nic */
+        if (nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC) {
+            continue;
+        }
+        if (has_name && strcmp(nc->name, name) != 0) {
+            continue;
+        }
+
+        if (nc->info->query_rx_filter) {
+            info = nc->info->query_rx_filter(nc);
+            entry = g_malloc0(sizeof(*entry));
+            entry->value = info;
+
+            if (!filter_list) {
+                filter_list = entry;
+            } else {
+                last_entry->next = entry;
+            }
+            last_entry = entry;
+        } else if (has_name) {
+            error_setg(errp, "net client(%s) doesn't support"
+                       " rx-filter querying", name);
+            break;
+        }
+    }
+
+    if (filter_list == NULL && !error_is_set(errp)) {
+        if (has_name) {
+            error_setg(errp, "invalid net client name: %s", name);
+        } else {
+            error_setg(errp, "no net client supports rx-filter querying");
+        }
+    }
+
+    return filter_list;
+}
+
 void do_info_network(Monitor *mon, const QDict *qdict)
 {
     NetClientState *nc, *peer;
diff --git a/qapi-schema.json b/qapi-schema.json
index 5ad6894..a69dc17 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3624,3 +3624,78 @@
             '*cpuid-input-ecx': 'int',
             'cpuid-register': 'X86CPURegister32',
             'features': 'int' } }
+
+##
+# @RxState:
+#
+# Packets receiving state
+#
+# @normal: filter assigned packets according to the mac-table
+#
+# @none: don't receive any assigned packet
+#
+# @all: receive all assigned packets
+#
+##
+{ 'enum': 'RxState', 'data': [ 'normal', 'none', 'all' ] }
+
+##
+# @RxFilterInfo:
+#
+# Rx-filter information for a nic.
+#
+# @name: net client name
+#
+# @promiscuous: whether promiscuous mode is enabled
+#
+# @multicast: multicast receive state
+#
+# @unicast: unicast receive state
+#
+# @broadcast-allowed: whether to receive broadcast
+#
+# @multicast-overflow: multicast table is overflowed or not
+#
+# @unicast-overflow: unicast table is overflowed or not
+#
+# @main-mac: the main macaddr string
+#
+# @vlan-table: a list of active vlan id
+#
+# @unicast-table: a list of unicast macaddr string
+#
+# @multicast-table: a list of multicast macaddr string
+#
+# Since 1.6
+##
+
+{ 'type': 'RxFilterInfo',
+  'data': {
+    'name':               'str',
+    'promiscuous':        'bool',
+    'multicast':          'RxState',
+    'unicast':            'RxState',
+    'broadcast-allowed':  'bool',
+    'multicast-overflow': 'bool',
+    'unicast-overflow':   'bool',
+    'main-mac':           'str',
+    'vlan-table':         ['int'],
+    'unicast-table':      ['str'],
+    'multicast-table':    ['str'] }}
+
+##
+# @query-rx-filter:
+#
+# Return rx-filter information for all nics (or for the given nic).
+#
+# @name: #optional net client name
+#
+# Returns: list of @RxFilterInfo for all nics (or for the given nic).
+#          Returns an error if the given @name doesn't exist, or given
+#          nic doesn't support rx-filter querying, or no net client
+#          supports rx-filter querying
+#
+# Since: 1.6
+##
+{ 'command': 'query-rx-filter', 'data': { '*name': 'str' },
+  'returns': ['RxFilterInfo'] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8cea5e5..aa00a94 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2997,3 +2997,66 @@ Example:
 <- { "return": {} }
 
 EQMP
+    {
+        .name       = "query-rx-filter",
+        .args_type  = "name:s?",
+        .mhandler.cmd_new = qmp_marshal_input_query_rx_filter,
+    },
+
+SQMP
+query-rx-filter
+---------------
+
+Show rx-filter information.
+
+Returns a json-array of rx-filter information for all nics (or for the
+given nic), returning an error if the given nic doesn't exist, or
+given nic doesn't support rx-filter querying, or no net client
+supports rx-filter querying.
+
+The query will clear the event notification flag of each nic, then qemu
+will start to emit event to QMP monitor.
+
+Each array entry contains the following:
+
+- "name": net client name (json-string)
+- "promiscuous": promiscuous mode is enabled (json-bool)
+- "multicast": multicast receive state (one of 'normal', 'none', 'all')
+- "unicast": unicast receive state  (one of 'normal', 'none', 'all')
+- "broadcast-allowed": allow to receive broadcast (json-bool)
+- "multicast-overflow": multicast table is overflowed (json-bool)
+- "unicast-overflow": unicast table is overflowed (json-bool)
+- "main-mac": main macaddr string (json-string)
+- "vlan-table": a json-array of active vlan id
+- "unicast-table": a json-array of unicast macaddr string
+- "multicast-table": a json-array of multicast macaddr string
+
+Example:
+
+-> { "execute": "query-rx-filter", "arguments": { "name": "vnet0" } }
+<- { "return": [
+        {
+            "promiscuous": true,
+            "name": "vnet0",
+            "main-mac": "52:54:00:12:34:56",
+            "unicast": "normal",
+            "vlan-table": [
+                4,
+                0
+            ],
+            "unicast-table": [
+            ],
+            "multicast": "normal",
+            "multicast-overflow": false,
+            "unicast-overflow": false,
+            "multicast-table": [
+                "01:00:5e:00:00:01",
+                "33:33:00:00:00:01",
+                "33:33:ff:12:34:56"
+            ],
+            "broadcast-allowed": false
+        }
+      ]
+   }
+
+EQMP
-- 
MST

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

* [Qemu-devel] [PULL 13/21] pci: Move pci_read_devaddr to pci-hotplug-old.c
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (9 preceding siblings ...)
  2013-06-20 13:10 ` [Qemu-devel] [PULL 11/21] net: add support of mac-programming over macvtap in QEMU side Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 14/21] pci: Abolish pci_find_root_bus() Michael S. Tsirkin
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

pci_read_devaddr() is only used by the legacy functions for the old PCI
hotplug interface in pci-hotplug-old.c.  So we move the function there,
and make it static.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c | 14 ++++++++++++++
 hw/pci/pci.c             | 16 +---------------
 include/hw/pci/pci.h     |  4 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index b3c233c..a0b5558 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -36,6 +36,20 @@
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
 
+static int pci_read_devaddr(Monitor *mon, const char *addr, int *domp,
+                            int *busp, unsigned *slotp)
+{
+    /* strip legacy tag */
+    if (!strncmp(addr, "pci_addr=", 9)) {
+        addr += 9;
+    }
+    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
+        monitor_printf(mon, "Invalid pci address\n");
+        return -1;
+    }
+    return 0;
+}
+
 static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
                                        const char *devaddr,
                                        const char *opts_str)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index a3eb19e..57724df 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -522,7 +522,7 @@ static void pci_set_default_subsystem_id(PCIDevice *pci_dev)
  * Parse [[<domain>:]<bus>:]<slot>, return -1 on error if funcp == NULL
  *       [[<domain>:]<bus>:]<slot>.<func>, return -1 on error
  */
-static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
                       unsigned int *slotp, unsigned int *funcp)
 {
     const char *p;
@@ -581,20 +581,6 @@ static int pci_parse_devaddr(const char *addr, int *domp, int *busp,
     return 0;
 }
 
-int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
-                     unsigned *slotp)
-{
-    /* strip legacy tag */
-    if (!strncmp(addr, "pci_addr=", 9)) {
-        addr += 9;
-    }
-    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
-        monitor_printf(mon, "Invalid pci address\n");
-        return -1;
-    }
-    return 0;
-}
-
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
 {
     int dom, bus;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 8d075ab..3ef2ee1 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -396,8 +396,8 @@ PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
 
-int pci_read_devaddr(Monitor *mon, const char *addr, int *domp, int *busp,
-                     unsigned *slotp);
+int pci_parse_devaddr(const char *addr, int *domp, int *busp,
+                      unsigned int *slotp, unsigned int *funcp);
 
 void pci_device_deassert_intx(PCIDevice *dev);
 
-- 
MST

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

* [Qemu-devel] [PULL 14/21] pci: Abolish pci_find_root_bus()
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (10 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 13/21] pci: Move pci_read_devaddr to pci-hotplug-old.c Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 15/21] pci: Use helper to find device's root bus in pci_find_domain() Michael S. Tsirkin
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

pci_find_root_bus() takes a domain parameter.  Currently PCI root buses
with domain other than 0 can't be created, so this is more or less a long
winded way of retrieving the main PCI root bus.  Numbered domains don't
actually properly cover the (non x86) possibilities for multiple PCI root
buses, so this patch for now enforces the domain == 0 restriction in other
places to replace pci_find_root_bus() with an explicit
pci_find_primary_bus().

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c | 34 +++++++++++++++++++++++++---------
 hw/pci/pci.c             | 19 +++++++++++++++----
 include/hw/pci/pci.h     |  2 +-
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index a0b5558..7a47d6b 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -36,17 +36,23 @@
 #include "sysemu/blockdev.h"
 #include "qapi/error.h"
 
-static int pci_read_devaddr(Monitor *mon, const char *addr, int *domp,
+static int pci_read_devaddr(Monitor *mon, const char *addr,
                             int *busp, unsigned *slotp)
 {
+    int dom;
+
     /* strip legacy tag */
     if (!strncmp(addr, "pci_addr=", 9)) {
         addr += 9;
     }
-    if (pci_parse_devaddr(addr, domp, busp, slotp, NULL)) {
+    if (pci_parse_devaddr(addr, &dom, busp, slotp, NULL)) {
         monitor_printf(mon, "Invalid pci address\n");
         return -1;
     }
+    if (dom != 0) {
+        monitor_printf(mon, "Multiple PCI domains not supported, use device_add\n");
+        return -1;
+    }
     return 0;
 }
 
@@ -128,18 +134,22 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 
 int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)
 {
-    int dom, pci_bus;
+    int pci_bus;
     unsigned slot;
+    PCIBus *root = pci_find_primary_bus();
     PCIDevice *dev;
     const char *pci_addr = qdict_get_str(qdict, "pci_addr");
 
     switch (dinfo->type) {
     case IF_SCSI:
-        if (pci_read_devaddr(mon, pci_addr, &dom, &pci_bus, &slot)) {
+        if (!root) {
+            monitor_printf(mon, "no primary PCI bus\n");
+            goto err;
+        }
+        if (pci_read_devaddr(mon, pci_addr, &pci_bus, &slot)) {
             goto err;
         }
-        dev = pci_find_device(pci_find_root_bus(dom), pci_bus,
-                              PCI_DEVFN(slot, 0));
+        dev = pci_find_device(root, pci_bus, PCI_DEVFN(slot, 0));
         if (!dev) {
             monitor_printf(mon, "no pci device with address %s\n", pci_addr);
             goto err;
@@ -275,16 +285,22 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 
 static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
 {
+    PCIBus *root = pci_find_primary_bus();
     PCIDevice *d;
-    int dom, bus;
+    int bus;
     unsigned slot;
     Error *local_err = NULL;
 
-    if (pci_read_devaddr(mon, pci_addr, &dom, &bus, &slot)) {
+    if (!root) {
+        monitor_printf(mon, "no primary PCI bus\n");
+        return -1;
+    }
+
+    if (pci_read_devaddr(mon, pci_addr, &bus, &slot)) {
         return -1;
     }
 
-    d = pci_find_device(pci_find_root_bus(dom), bus, PCI_DEVFN(slot, 0));
+    d = pci_find_device(root, bus, PCI_DEVFN(slot, 0));
     if (!d) {
         monitor_printf(mon, "slot %d empty\n", slot);
         return -1;
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 57724df..b8c6140 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -246,12 +246,12 @@ static void pci_host_bus_register(int domain, PCIBus *bus)
     QLIST_INSERT_HEAD(&host_buses, host, next);
 }
 
-PCIBus *pci_find_root_bus(int domain)
+PCIBus *pci_find_primary_bus(void)
 {
     struct PCIHostBus *host;
 
     QLIST_FOREACH(host, &host_buses, next) {
-        if (host->domain == domain) {
+        if (host->domain == 0) {
             return host->bus;
         }
     }
@@ -583,20 +583,31 @@ int pci_parse_devaddr(const char *addr, int *domp, int *busp,
 
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
 {
+    PCIBus *root = pci_find_primary_bus();
     int dom, bus;
     unsigned slot;
 
+    if (!root) {
+        fprintf(stderr, "No primary PCI bus\n");
+        return NULL;
+    }
+
     if (!devaddr) {
         *devfnp = -1;
-        return pci_find_bus_nr(pci_find_root_bus(0), 0);
+        return pci_find_bus_nr(root, 0);
     }
 
     if (pci_parse_devaddr(devaddr, &dom, &bus, &slot, NULL) < 0) {
         return NULL;
     }
 
+    if (dom != 0) {
+        fprintf(stderr, "No support for non-zero PCI domains\n");
+        return NULL;
+    }
+
     *devfnp = PCI_DEVFN(slot, 0);
-    return pci_find_bus_nr(pci_find_root_bus(dom), bus);
+    return pci_find_bus_nr(root, bus);
 }
 
 static void pci_init_cmask(PCIDevice *dev)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 3ef2ee1..c26d704 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -390,7 +390,7 @@ int pci_bus_num(PCIBus *s);
 void pci_for_each_device(PCIBus *bus, int bus_num,
                          void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
                          void *opaque);
-PCIBus *pci_find_root_bus(int domain);
+PCIBus *pci_find_primary_bus(void);
 int pci_find_domain(const PCIBus *bus);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
-- 
MST

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

* [Qemu-devel] [PULL 15/21] pci: Use helper to find device's root bus in pci_find_domain()
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (11 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 14/21] pci: Abolish pci_find_root_bus() Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 16/21] pci: Replace pci_find_domain() with more general pci_root_bus_path() Michael S. Tsirkin
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

Currently pci_find_domain() performs two functions - it locates the PCI
root bus above the given bus, then looks up that root bus's domain number.
This patch adds a helper function to perform the first task, finding the
root bus for a given PCI device.  This is then used in pci_find_domain().
This changes pci_find_domain()'s signature slightly, taking a PCIDevice
instead of a PCIBus - since all callers passed something of the form
dev->bus, this simplifies things slightly.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c |  2 +-
 hw/pci/pci.c             | 20 +++++++++++++-------
 hw/pci/pcie_aer.c        |  3 +--
 include/hw/pci/pci.h     |  3 ++-
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index 7a47d6b..37e0720 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -276,7 +276,7 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
 
     if (dev) {
         monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
-                       pci_find_domain(dev->bus),
+                       pci_find_domain(dev),
                        pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
                        PCI_FUNC(dev->devfn));
     } else
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b8c6140..bab992d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -259,18 +259,24 @@ PCIBus *pci_find_primary_bus(void)
     return NULL;
 }
 
-int pci_find_domain(const PCIBus *bus)
+PCIBus *pci_device_root_bus(const PCIDevice *d)
 {
-    PCIDevice *d;
-    struct PCIHostBus *host;
+    PCIBus *bus = d->bus;
 
-    /* obtain root bus */
     while ((d = bus->parent_dev) != NULL) {
         bus = d->bus;
     }
 
+    return bus;
+}
+
+int pci_find_domain(const PCIDevice *dev)
+{
+    const PCIBus *rootbus = pci_device_root_bus(dev);
+    struct PCIHostBus *host;
+
     QLIST_FOREACH(host, &host_buses, next) {
-        if (host->bus == bus) {
+        if (host->bus == rootbus) {
             return host->domain;
         }
     }
@@ -2000,7 +2006,7 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
                 fprintf(stderr, "ERROR: %04x:%02x:%02x.%x "
                         "Attempt to add PCI capability %x at offset "
                         "%x overlaps existing capability %x at offset %x\n",
-                        pci_find_domain(pdev->bus), pci_bus_num(pdev->bus),
+                        pci_find_domain(pdev), pci_bus_num(pdev->bus),
                         PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
                         cap_id, offset, overlapping_cap, i);
                 return -EINVAL;
@@ -2155,7 +2161,7 @@ static char *pcibus_get_dev_path(DeviceState *dev)
     path[path_len] = '\0';
 
     /* First field is the domain. */
-    s = snprintf(domain, sizeof domain, "%04x:00", pci_find_domain(d->bus));
+    s = snprintf(domain, sizeof domain, "%04x:00", pci_find_domain(d));
     assert(s == domain_len);
     memcpy(path, domain, domain_len);
 
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index 1ce72ce..06f77ac 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -1022,8 +1022,7 @@ int do_pcie_aer_inject_error(Monitor *mon,
     *ret_data = qobject_from_jsonf("{'id': %s, "
                                    "'domain': %d, 'bus': %d, 'devfn': %d, "
                                    "'ret': %d}",
-                                   id,
-                                   pci_find_domain(dev->bus),
+                                   id, pci_find_domain(dev),
                                    pci_bus_num(dev->bus), dev->devfn,
                                    ret);
     assert(*ret_data);
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index c26d704..7376b9e 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -391,7 +391,8 @@ void pci_for_each_device(PCIBus *bus, int bus_num,
                          void (*fn)(PCIBus *bus, PCIDevice *d, void *opaque),
                          void *opaque);
 PCIBus *pci_find_primary_bus(void);
-int pci_find_domain(const PCIBus *bus);
+PCIBus *pci_device_root_bus(const PCIDevice *d);
+int pci_find_domain(const PCIDevice *dev);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
-- 
MST

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

* [Qemu-devel] [PULL 16/21] pci: Replace pci_find_domain() with more general pci_root_bus_path()
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (12 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 15/21] pci: Use helper to find device's root bus in pci_find_domain() Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 17/21] pci: Add root bus argument to pci_get_bus_devfn() Michael S. Tsirkin
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Alexander Graf, Alex Williamson, qemu-ppc,
	Paolo Bonzini, Laszlo Ersek, =?UTF-8?q?Andreas=20F=C3=A4rber?=,
	David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

pci_find_domain() is used in a number of places where we want an id for a
whole PCI domain (i.e. the subtree under a PCI root bus).  The trouble is
that many platforms may support multiple independent host bridges with no
hardware supplied notion of domain number.

This patch, therefore, replaces calls to pci_find_domain() with calls to
a new pci_root_bus_path() returning a string.  The new call is implemented
in terms of a new callback in the host bridge class, so it can be defined
in some way that's well defined for the platform.  When no callback is
available we fall back on the qbus name.

Most current uses of pci_find_domain() are for error or informational
messages, so the change in identifiers should be harmless.  The exception
is pci_get_dev_path(), whose results form part of migration streams.  To
maintain compatibility with old migration streams, the PIIX PCI host is
altered to always supply "0000" for this path, which matches the old domain
number (since the code didn't actually support domains other than 0).

For the pseries (spapr) PCI bridge we use a different platform-unique
identifier (pseries machines can routinely have dozens of PCI host
bridges).  Theoretically that breaks migration streams, but given that we
don't yet have migration support for pseries, it doesn't matter.

Any other machines that have working migration support including PCI
devices will need to be updated to maintain migration stream compatibility.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci-host/piix.c        |  9 +++++++++
 hw/pci-host/q35.c         |  9 +++++++++
 hw/pci/pci-hotplug-old.c  |  4 ++--
 hw/pci/pci.c              | 38 ++++++++++++++++++++------------------
 hw/pci/pci_host.c         |  1 +
 hw/pci/pcie_aer.c         |  8 ++++----
 hw/ppc/spapr_pci.c        | 10 ++++++++++
 include/hw/pci/pci.h      |  2 +-
 include/hw/pci/pci_host.h | 10 ++++++++++
 9 files changed, 66 insertions(+), 25 deletions(-)

diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index f9e68c3..c36e725 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -629,11 +629,20 @@ static const TypeInfo i440fx_info = {
     .class_init    = i440fx_class_init,
 };
 
+static const char *i440fx_pcihost_root_bus_path(PCIHostState *host_bridge,
+                                                PCIBus *rootbus)
+{
+    /* For backwards compat with old device paths */
+    return "0000";
+}
+
 static void i440fx_pcihost_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
 
+    hc->root_bus_path = i440fx_pcihost_root_bus_path;
     k->init = i440fx_pcihost_initfn;
     dc->fw_name = "pci";
     dc->no_user = 1;
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 3a5cff9..13148ed 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -63,6 +63,13 @@ static int q35_host_init(SysBusDevice *dev)
     return 0;
 }
 
+static const char *q35_host_root_bus_path(PCIHostState *host_bridge,
+                                          PCIBus *rootbus)
+{
+    /* For backwards compat with old device paths */
+    return "0000";
+}
+
 static Property mch_props[] = {
     DEFINE_PROP_UINT64("MCFG", Q35PCIHost, host.base_addr,
                         MCH_HOST_BRIDGE_PCIEXBAR_DEFAULT),
@@ -73,7 +80,9 @@ static void q35_host_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
 
+    hc->root_bus_path = q35_host_root_bus_path;
     k->init = q35_host_init;
     dc->props = mch_props;
     dc->fw_name = "pci";
diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index 37e0720..e251810 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -275,8 +275,8 @@ void pci_device_hot_add(Monitor *mon, const QDict *qdict)
     }
 
     if (dev) {
-        monitor_printf(mon, "OK domain %d, bus %d, slot %d, function %d\n",
-                       pci_find_domain(dev),
+        monitor_printf(mon, "OK root bus %s, bus %d, slot %d, function %d\n",
+                       pci_root_bus_path(dev),
                        pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
                        PCI_FUNC(dev->devfn));
     } else
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index bab992d..0d0609f 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -25,6 +25,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_bridge.h"
 #include "hw/pci/pci_bus.h"
+#include "hw/pci/pci_host.h"
 #include "monitor/monitor.h"
 #include "net/net.h"
 #include "sysemu/sysemu.h"
@@ -270,19 +271,20 @@ PCIBus *pci_device_root_bus(const PCIDevice *d)
     return bus;
 }
 
-int pci_find_domain(const PCIDevice *dev)
+const char *pci_root_bus_path(PCIDevice *dev)
 {
-    const PCIBus *rootbus = pci_device_root_bus(dev);
-    struct PCIHostBus *host;
+    PCIBus *rootbus = pci_device_root_bus(dev);
+    PCIHostState *host_bridge = PCI_HOST_BRIDGE(rootbus->qbus.parent);
+    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_GET_CLASS(host_bridge);
 
-    QLIST_FOREACH(host, &host_buses, next) {
-        if (host->bus == rootbus) {
-            return host->domain;
-        }
+    assert(!rootbus->parent_dev);
+    assert(host_bridge->bus == rootbus);
+
+    if (hc->root_bus_path) {
+        return (*hc->root_bus_path)(host_bridge, rootbus);
     }
 
-    abort();    /* should not be reached */
-    return -1;
+    return rootbus->qbus.name;
 }
 
 static void pci_bus_init(PCIBus *bus, DeviceState *parent,
@@ -2003,10 +2005,10 @@ int pci_add_capability(PCIDevice *pdev, uint8_t cap_id,
         for (i = offset; i < offset + size; i++) {
             overlapping_cap = pci_find_capability_at_offset(pdev, i);
             if (overlapping_cap) {
-                fprintf(stderr, "ERROR: %04x:%02x:%02x.%x "
+                fprintf(stderr, "ERROR: %s:%02x:%02x.%x "
                         "Attempt to add PCI capability %x at offset "
                         "%x overlaps existing capability %x at offset %x\n",
-                        pci_find_domain(pdev), pci_bus_num(pdev->bus),
+                        pci_root_bus_path(pdev), pci_bus_num(pdev->bus),
                         PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
                         cap_id, offset, overlapping_cap, i);
                 return -EINVAL;
@@ -2140,30 +2142,30 @@ static char *pcibus_get_dev_path(DeviceState *dev)
      * domain:Bus:Slot.Func for systems without nested PCI bridges.
      * Slot.Function list specifies the slot and function numbers for all
      * devices on the path from root to the specific device. */
-    char domain[] = "DDDD:00";
+    const char *root_bus_path;
+    int root_bus_len;
     char slot[] = ":SS.F";
-    int domain_len = sizeof domain - 1 /* For '\0' */;
     int slot_len = sizeof slot - 1 /* For '\0' */;
     int path_len;
     char *path, *p;
     int s;
 
+    root_bus_path = pci_root_bus_path(d);
+    root_bus_len = strlen(root_bus_path);
+
     /* Calculate # of slots on path between device and root. */;
     slot_depth = 0;
     for (t = d; t; t = t->bus->parent_dev) {
         ++slot_depth;
     }
 
-    path_len = domain_len + slot_len * slot_depth;
+    path_len = root_bus_len + slot_len * slot_depth;
 
     /* Allocate memory, fill in the terminating null byte. */
     path = g_malloc(path_len + 1 /* For '\0' */);
     path[path_len] = '\0';
 
-    /* First field is the domain. */
-    s = snprintf(domain, sizeof domain, "%04x:00", pci_find_domain(d));
-    assert(s == domain_len);
-    memcpy(path, domain, domain_len);
+    memcpy(path, root_bus_path, root_bus_len);
 
     /* Fill in slot numbers. We walk up from device to root, so need to print
      * them in the reverse order, last to first. */
diff --git a/hw/pci/pci_host.c b/hw/pci/pci_host.c
index 12254b1..7dd9b25 100644
--- a/hw/pci/pci_host.c
+++ b/hw/pci/pci_host.c
@@ -169,6 +169,7 @@ static const TypeInfo pci_host_type_info = {
     .name = TYPE_PCI_HOST_BRIDGE,
     .parent = TYPE_SYS_BUS_DEVICE,
     .abstract = true,
+    .class_size = sizeof(PCIHostBridgeClass),
     .instance_size = sizeof(PCIHostState),
 };
 
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index 06f77ac..ca762ab 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -817,9 +817,9 @@ void pcie_aer_inject_error_print(Monitor *mon, const QObject *data)
     qdict = qobject_to_qdict(data);
 
     devfn = (int)qdict_get_int(qdict, "devfn");
-    monitor_printf(mon, "OK id: %s domain: %x, bus: %x devfn: %x.%x\n",
+    monitor_printf(mon, "OK id: %s root bus: %s, bus: %x devfn: %x.%x\n",
                    qdict_get_str(qdict, "id"),
-                   (int) qdict_get_int(qdict, "domain"),
+                   qdict_get_str(qdict, "root_bus"),
                    (int) qdict_get_int(qdict, "bus"),
                    PCI_SLOT(devfn), PCI_FUNC(devfn));
 }
@@ -1020,9 +1020,9 @@ int do_pcie_aer_inject_error(Monitor *mon,
 
     ret = pcie_aer_inject_error(dev, &err);
     *ret_data = qobject_from_jsonf("{'id': %s, "
-                                   "'domain': %d, 'bus': %d, 'devfn': %d, "
+                                   "'root_bus': %s, 'bus': %d, 'devfn': %d, "
                                    "'ret': %d}",
-                                   id, pci_find_domain(dev),
+                                   id, pci_root_bus_path(dev),
                                    pci_bus_num(dev->bus), dev->devfn,
                                    ret);
     assert(*ret_data);
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 62ff323..2d102f5 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -693,11 +693,21 @@ static Property spapr_phb_properties[] = {
     DEFINE_PROP_END_OF_LIST(),
 };
 
+static const char *spapr_phb_root_bus_path(PCIHostState *host_bridge,
+                                           PCIBus *rootbus)
+{
+    sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(host_bridge);
+
+    return sphb->dtbusname;
+}
+
 static void spapr_phb_class_init(ObjectClass *klass, void *data)
 {
+    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
     SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
 
+    hc->root_bus_path = spapr_phb_root_bus_path;
     sdc->init = spapr_phb_init;
     dc->props = spapr_phb_properties;
     dc->reset = spapr_phb_reset;
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 7376b9e..962b7a3 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -392,7 +392,7 @@ void pci_for_each_device(PCIBus *bus, int bus_num,
                          void *opaque);
 PCIBus *pci_find_primary_bus(void);
 PCIBus *pci_device_root_bus(const PCIDevice *d);
-int pci_find_domain(const PCIDevice *dev);
+const char *pci_root_bus_path(PCIDevice *dev);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
 PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h
index 236cd0f..44052f2 100644
--- a/include/hw/pci/pci_host.h
+++ b/include/hw/pci/pci_host.h
@@ -33,6 +33,10 @@
 #define TYPE_PCI_HOST_BRIDGE "pci-host-bridge"
 #define PCI_HOST_BRIDGE(obj) \
     OBJECT_CHECK(PCIHostState, (obj), TYPE_PCI_HOST_BRIDGE)
+#define PCI_HOST_BRIDGE_CLASS(klass) \
+     OBJECT_CLASS_CHECK(PCIHostBridgeClass, (klass), TYPE_PCI_HOST_BRIDGE)
+#define PCI_HOST_BRIDGE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(PCIHostBridgeClass, (obj), TYPE_PCI_HOST_BRIDGE)
 
 struct PCIHostState {
     SysBusDevice busdev;
@@ -44,6 +48,12 @@ struct PCIHostState {
     PCIBus *bus;
 };
 
+typedef struct PCIHostBridgeClass {
+    SysBusDeviceClass parent_class;
+
+    const char *(*root_bus_path)(PCIHostState *, PCIBus *);
+} PCIHostBridgeClass;
+
 /* common internal helpers for PCI/PCIe hosts, cut off overflows */
 void pci_host_config_write_common(PCIDevice *pci_dev, uint32_t addr,
                                   uint32_t limit, uint32_t val, uint32_t len);
-- 
MST

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

* [Qemu-devel] [PULL 17/21] pci: Add root bus argument to pci_get_bus_devfn()
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (13 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 16/21] pci: Replace pci_find_domain() with more general pci_root_bus_path() Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init() Michael S. Tsirkin
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

pci_get_bus_devfn() interprets a full PCI address string to give a PCIBus *
and device/function number within that bus.  Currently it assumes it is
working on an address under the primary PCI root bus.  This patch extends
it to allow the caller to specify a root bus.  This might seem a little odd
since the supplied address can (theoretically) include a PCI domain number.
However, attempting to use a non-zero domain number there is currently an
error, so that shouldn't really cause problems.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c | 4 ++--
 hw/pci/pci.c             | 7 ++++---
 include/hw/pci/pci.h     | 2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index e251810..e92d646 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -65,7 +65,7 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
     PCIBus *bus;
     int ret, devfn;
 
-    bus = pci_get_bus_devfn(&devfn, devaddr);
+    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
     if (!bus) {
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
@@ -205,7 +205,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
         dinfo = NULL;
     }
 
-    bus = pci_get_bus_devfn(&devfn, devaddr);
+    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
     if (!bus) {
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 0d0609f..c91b7f2 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -589,12 +589,13 @@ int pci_parse_devaddr(const char *addr, int *domp, int *busp,
     return 0;
 }
 
-PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr)
+PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr)
 {
-    PCIBus *root = pci_find_primary_bus();
     int dom, bus;
     unsigned slot;
 
+    assert(!root->parent_dev);
+
     if (!root) {
         fprintf(stderr, "No primary PCI bus\n");
         return NULL;
@@ -1591,7 +1592,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
     if (i < 0)
         return NULL;
 
-    bus = pci_get_bus_devfn(&devfn, devaddr);
+    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
     if (!bus) {
         error_report("Invalid PCI device address %s for device %s",
                      devaddr, pci_nic_names[i]);
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 962b7a3..3b22898 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -395,7 +395,7 @@ PCIBus *pci_device_root_bus(const PCIDevice *d);
 const char *pci_root_bus_path(PCIDevice *dev);
 PCIDevice *pci_find_device(PCIBus *bus, int bus_num, uint8_t devfn);
 int pci_qdev_find_device(const char *id, PCIDevice **pdev);
-PCIBus *pci_get_bus_devfn(int *devfnp, const char *devaddr);
+PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr);
 
 int pci_parse_devaddr(const char *addr, int *domp, int *busp,
                       unsigned int *slotp, unsigned int *funcp);
-- 
MST

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

* [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init()
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (14 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 17/21] pci: Add root bus argument to pci_get_bus_devfn() Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 17:07   ` Richard Henderson
  2013-06-20 13:11 ` [Qemu-devel] [PULL 19/21] pci: Simpler implementation of primary PCI bus Michael S. Tsirkin
                   ` (4 subsequent siblings)
  20 siblings, 1 reply; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Anthony Liguori, Stefan Weil, Alexander Graf,
	Blue Swirl, Avik Sil, =?UTF-8?q?Andreas=20F=C3=A4rber?=,
	qemu-ppc, Paul Brook, Scott Wood, Paolo Bonzini, David Gibson,
	Aurelien Jarno, Richard Henderson

From: David Gibson <david@gibson.dropbear.id.au>

At present, pci_nic_init() and pci_nic_init_nofail() assume that they will
only create a NIC under the primary PCI root.  As we add support for
multiple PCI roots, that may no longer be the case.  This patch adds a root
bus parameter to pci_nic_init() (and updates callers accordingly) to allow
the machine init code using it to specify the right PCI root for NICs
created by old-style -net nic parameters.  NICs created new-style, with
-device can of course be put anywhere.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/alpha/dp264.c         |  2 +-
 hw/arm/realview.c        |  6 ++++--
 hw/arm/versatilepb.c     |  2 +-
 hw/i386/pc.c             |  2 +-
 hw/mips/mips_fulong2e.c  |  6 +++---
 hw/mips/mips_malta.c     |  6 +++---
 hw/pci/pci-hotplug-old.c |  3 ++-
 hw/pci/pci.c             | 10 ++++++----
 hw/ppc/e500.c            |  2 +-
 hw/ppc/mac_newworld.c    |  2 +-
 hw/ppc/mac_oldworld.c    |  2 +-
 hw/ppc/ppc440_bamboo.c   |  2 +-
 hw/ppc/prep.c            |  2 +-
 hw/ppc/spapr.c           |  2 +-
 hw/sh4/r2d.c             |  5 ++++-
 hw/sparc64/sun4u.c       |  2 +-
 include/hw/pci/pci.h     |  6 ++++--
 17 files changed, 36 insertions(+), 26 deletions(-)

diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 8695efb..8dad08f 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -89,7 +89,7 @@ static void clipper_init(QEMUMachineInitArgs *args)
 
     /* Network setup.  e1000 is good enough, failing Tulip support.  */
     for (i = 0; i < nb_nics; i++) {
-        pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
+        pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
     }
 
     /* IDE disk setup.  */
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index d6f47bf..036a188 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -59,7 +59,7 @@ static void realview_init(QEMUMachineInitArgs *args,
     qemu_irq *irqp;
     qemu_irq pic[64];
     qemu_irq mmc_irq[2];
-    PCIBus *pci_bus;
+    PCIBus *pci_bus = NULL;
     NICInfo *nd;
     i2c_bus *i2c;
     int n;
@@ -250,7 +250,9 @@ static void realview_init(QEMUMachineInitArgs *args,
             }
             done_nic = 1;
         } else {
-            pci_nic_init_nofail(nd, "rtl8139", NULL);
+            if (pci_bus) {
+                pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL);
+            }
         }
     }
 
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 753757e..15eb086 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -244,7 +244,7 @@ static void versatile_init(QEMUMachineInitArgs *args, int board_id)
             smc91c111_init(nd, 0x10010000, sic[25]);
             done_smc = 1;
         } else {
-            pci_nic_init_nofail(nd, "rtl8139", NULL);
+            pci_nic_init_nofail(nd, pci_bus, "rtl8139", NULL);
         }
     }
     if (usb_enabled(false)) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e1ed760..5e65a09 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1311,7 +1311,7 @@ void pc_nic_init(ISABus *isa_bus, PCIBus *pci_bus)
         if (!pci_bus || (nd->model && strcmp(nd->model, "ne2k_isa") == 0)) {
             pc_init_ne2k_isa(isa_bus, nd);
         } else {
-            pci_nic_init_nofail(nd, "e1000", NULL);
+            pci_nic_init_nofail(nd, pci_bus, "e1000", NULL);
         }
     }
 }
diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 1aac93a..cf2bd62 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -231,7 +231,7 @@ static void audio_init (PCIBus *pci_bus)
 }
 
 /* Network support */
-static void network_init (void)
+static void network_init (PCIBus *pci_bus)
 {
     int i;
 
@@ -244,7 +244,7 @@ static void network_init (void)
             default_devaddr = "07";
         }
 
-        pci_nic_init_nofail(nd, "rtl8139", default_devaddr);
+        pci_nic_init_nofail(nd, pci_bus, "rtl8139", default_devaddr);
     }
 }
 
@@ -393,7 +393,7 @@ static void mips_fulong2e_init(QEMUMachineInitArgs *args)
     /* Sound card */
     audio_init(pci_bus);
     /* Network card */
-    network_init();
+    network_init(pci_bus);
 }
 
 static QEMUMachine mips_fulong2e_machine = {
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index 5033d51..05e59b4 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -468,7 +468,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
 }
 
 /* Network support */
-static void network_init(void)
+static void network_init(PCIBus *pci_bus)
 {
     int i;
 
@@ -480,7 +480,7 @@ static void network_init(void)
             /* The malta board has a PCNet card using PCI SLOT 11 */
             default_devaddr = "0b";
 
-        pci_nic_init_nofail(nd, "pcnet", default_devaddr);
+        pci_nic_init_nofail(nd, pci_bus, "pcnet", default_devaddr);
     }
 }
 
@@ -985,7 +985,7 @@ void mips_malta_init(QEMUMachineInitArgs *args)
     fdctrl_init_isa(isa_bus, fd);
 
     /* Network card */
-    network_init();
+    network_init(pci_bus);
 
     /* Optional PCI video card */
     pci_vga_init(pci_bus);
diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index e92d646..807260c 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -92,7 +92,8 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
         monitor_printf(mon, "Parameter addr not supported\n");
         return NULL;
     }
-    return pci_nic_init(&nd_table[ret], "rtl8139", devaddr);
+    return pci_nic_init(&nd_table[ret], pci_find_primary_bus(),
+                        "rtl8139", devaddr);
 }
 
 static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index c91b7f2..6747ac5 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1578,7 +1578,8 @@ static const char * const pci_nic_names[] = {
 
 /* Initialize a PCI NIC.  */
 /* FIXME callers should check for failure, but don't */
-PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
+PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus,
+                        const char *default_model,
                         const char *default_devaddr)
 {
     const char *devaddr = nd->devaddr ? nd->devaddr : default_devaddr;
@@ -1592,7 +1593,7 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
     if (i < 0)
         return NULL;
 
-    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
+    bus = pci_get_bus_devfn(&devfn, rootbus, devaddr);
     if (!bus) {
         error_report("Invalid PCI device address %s for device %s",
                      devaddr, pci_nic_names[i]);
@@ -1607,7 +1608,8 @@ PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
     return pci_dev;
 }
 
-PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
+PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
+                               const char *default_model,
                                const char *default_devaddr)
 {
     PCIDevice *res;
@@ -1615,7 +1617,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
     if (qemu_show_nic_models(nd->model, pci_nic_models))
         exit(0);
 
-    res = pci_nic_init(nd, default_model, default_devaddr);
+    res = pci_nic_init(nd, rootbus, default_model, default_devaddr);
     if (!res)
         exit(1);
     return res;
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index c9ae512..302f608 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -626,7 +626,7 @@ void ppce500_init(PPCE500Params *params)
     if (pci_bus) {
         /* Register network interfaces. */
         for (i = 0; i < nb_nics; i++) {
-            pci_nic_init_nofail(&nd_table[i], "virtio", NULL);
+            pci_nic_init_nofail(&nd_table[i], pci_bus, "virtio", NULL);
         }
     }
 
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index ce44e95..af5b077 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -362,7 +362,7 @@ static void ppc_core99_init(QEMUMachineInitArgs *args)
                              escc_mem, 0, memory_region_size(escc_mem));
 
     for(i = 0; i < nb_nics; i++)
-        pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
+        pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
 
     ide_drive_get(hd, MAX_IDE_BUS);
 
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 3acca94..2a43027 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -259,7 +259,7 @@ static void ppc_heathrow_init(QEMUMachineInitArgs *args)
                              escc_mem, 0, memory_region_size(escc_mem));
 
     for(i = 0; i < nb_nics; i++)
-        pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
+        pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
 
 
     ide_drive_get(hd, MAX_IDE_BUS);
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index a55e717..8bb9343 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -245,7 +245,7 @@ static void bamboo_init(QEMUMachineInitArgs *args)
         for (i = 0; i < nb_nics; i++) {
             /* There are no PCI NICs on the Bamboo board, but there are
              * PCI slots, so we can pick whatever default model we want. */
-            pci_nic_init_nofail(&nd_table[i], "e1000", NULL);
+            pci_nic_init_nofail(&nd_table[i], pcibus, "e1000", NULL);
         }
     }
 
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 4fdc164..4d96862 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -628,7 +628,7 @@ static void ppc_prep_init(QEMUMachineInitArgs *args)
             isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i],
                             &nd_table[i]);
         } else {
-            pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
+            pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
         }
     }
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 218ea23..41a2e49 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -887,7 +887,7 @@ static void ppc_spapr_init(QEMUMachineInitArgs *args)
         if (strcmp(nd->model, "ibmveth") == 0) {
             spapr_vlan_create(spapr->vio_bus, nd);
         } else {
-            pci_nic_init_nofail(&nd_table[i], nd->model, NULL);
+            pci_nic_init_nofail(&nd_table[i], phb->bus, nd->model, NULL);
         }
     }
 
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 3e4818e..dd81d75 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -236,6 +236,7 @@ static void r2d_init(QEMUMachineInitArgs *args)
     DeviceState *dev;
     SysBusDevice *busdev;
     MemoryRegion *address_space_mem = get_system_memory();
+    PCIBus *pci_bus;
 
     if (cpu_model == NULL) {
         cpu_model = "SH7751R";
@@ -264,6 +265,7 @@ static void r2d_init(QEMUMachineInitArgs *args)
     dev = qdev_create(NULL, "sh_pci");
     busdev = SYS_BUS_DEVICE(dev);
     qdev_init_nofail(dev);
+    pci_bus = PCI_BUS(qdev_get_child_bus(dev, "pci"));
     sysbus_mmio_map(busdev, 0, P4ADDR(0x1e200000));
     sysbus_mmio_map(busdev, 1, A7ADDR(0x1e200000));
     sysbus_connect_irq(busdev, 0, irq[PCI_INTA]);
@@ -295,7 +297,8 @@ static void r2d_init(QEMUMachineInitArgs *args)
 
     /* NIC: rtl8139 on-board, and 2 slots. */
     for (i = 0; i < nb_nics; i++)
-        pci_nic_init_nofail(&nd_table[i], "rtl8139", i==0 ? "2" : NULL);
+        pci_nic_init_nofail(&nd_table[i], pci_bus,
+                            "rtl8139", i==0 ? "2" : NULL);
 
     /* USB keyboard */
     usbdevice_create("keyboard");
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index a6a3b76..19dd954 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -854,7 +854,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
     }
 
     for(i = 0; i < nb_nics; i++)
-        pci_nic_init_nofail(&nd_table[i], "ne2k_pci", NULL);
+        pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL);
 
     ide_drive_get(hd, MAX_IDE_BUS);
 
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 3b22898..ecceeba 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -379,9 +379,11 @@ void pci_device_set_intx_routing_notifier(PCIDevice *dev,
 void pci_device_reset(PCIDevice *dev);
 void pci_bus_reset(PCIBus *bus);
 
-PCIDevice *pci_nic_init(NICInfo *nd, const char *default_model,
+PCIDevice *pci_nic_init(NICInfo *nd, PCIBus *rootbus,
+                        const char *default_model,
                         const char *default_devaddr);
-PCIDevice *pci_nic_init_nofail(NICInfo *nd, const char *default_model,
+PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
+                               const char *default_model,
                                const char *default_devaddr);
 
 PCIDevice *pci_vga_init(PCIBus *bus);
-- 
MST

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

* [Qemu-devel] [PULL 19/21] pci: Simpler implementation of primary PCI bus
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (15 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init() Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:11 ` [Qemu-devel] [PULL 20/21] pci: Remove domain from PCIHostBus Michael S. Tsirkin
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

Currently pci_find_primary_bus() searches the list of root buses for one
with domain 0.  But since host buses are always registered with domain 0,
this just amounts to finding the only PCI host bus.  The only remaining
users of pci_find_primary_bus() are in pci-hotplug-old.c, which implements
the old style pci_add/pci_del commands.

Therefore, this patch redefines pci_find_primary_bus() to find the only
PCI root bus, returning an error if there are multiple roots.  The callers
in pci-hotplug-old.c are updated correspondingly, to produce sensible
error messages.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c | 26 ++++++++++++++++++++------
 hw/pci/pci.c             |  9 ++++++---
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index 807260c..8077289 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -62,10 +62,17 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
 {
     Error *local_err = NULL;
     QemuOpts *opts;
+    PCIBus *root = pci_find_primary_bus();
     PCIBus *bus;
     int ret, devfn;
 
-    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
+    if (!root) {
+        monitor_printf(mon, "no primary PCI bus (if there are multiple"
+                       " PCI roots, you must use device_add instead)");
+        return NULL;
+    }
+
+    bus = pci_get_bus_devfn(&devfn, root, devaddr);
     if (!bus) {
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
@@ -92,8 +99,7 @@ static PCIDevice *qemu_pci_hot_add_nic(Monitor *mon,
         monitor_printf(mon, "Parameter addr not supported\n");
         return NULL;
     }
-    return pci_nic_init(&nd_table[ret], pci_find_primary_bus(),
-                        "rtl8139", devaddr);
+    return pci_nic_init(&nd_table[ret], root, "rtl8139", devaddr);
 }
 
 static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
@@ -144,7 +150,8 @@ int pci_drive_hot_add(Monitor *mon, const QDict *qdict, DriveInfo *dinfo)
     switch (dinfo->type) {
     case IF_SCSI:
         if (!root) {
-            monitor_printf(mon, "no primary PCI bus\n");
+            monitor_printf(mon, "no primary PCI bus (if there are multiple"
+                           " PCI roots, you must use device_add instead)");
             goto err;
         }
         if (pci_read_devaddr(mon, pci_addr, &pci_bus, &slot)) {
@@ -177,6 +184,7 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
     DriveInfo *dinfo = NULL;
     int type = -1;
     char buf[128];
+    PCIBus *root = pci_find_primary_bus();
     PCIBus *bus;
     int devfn;
 
@@ -206,7 +214,12 @@ static PCIDevice *qemu_pci_hot_add_storage(Monitor *mon,
         dinfo = NULL;
     }
 
-    bus = pci_get_bus_devfn(&devfn, pci_find_primary_bus(), devaddr);
+    if (!root) {
+        monitor_printf(mon, "no primary PCI bus (if there are multiple"
+                       " PCI roots, you must use device_add instead)");
+        return NULL;
+    }
+    bus = pci_get_bus_devfn(&devfn, root, devaddr);
     if (!bus) {
         monitor_printf(mon, "Invalid PCI device address %s\n", devaddr);
         return NULL;
@@ -293,7 +306,8 @@ static int pci_device_hot_remove(Monitor *mon, const char *pci_addr)
     Error *local_err = NULL;
 
     if (!root) {
-        monitor_printf(mon, "no primary PCI bus\n");
+        monitor_printf(mon, "no primary PCI bus (if there are multiple"
+                       " PCI roots, you must use device_del instead)");
         return -1;
     }
 
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6747ac5..75513eb 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -249,15 +249,18 @@ static void pci_host_bus_register(int domain, PCIBus *bus)
 
 PCIBus *pci_find_primary_bus(void)
 {
+    PCIBus *primary_bus = NULL;
     struct PCIHostBus *host;
 
     QLIST_FOREACH(host, &host_buses, next) {
-        if (host->domain == 0) {
-            return host->bus;
+        if (primary_bus) {
+            /* We have multiple root buses, refuse to select a primary */
+            return NULL;
         }
+        primary_bus = host->bus;
     }
 
-    return NULL;
+    return primary_bus;
 }
 
 PCIBus *pci_device_root_bus(const PCIDevice *d)
-- 
MST

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

* [Qemu-devel] [PULL 20/21] pci: Remove domain from PCIHostBus
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (16 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 19/21] pci: Simpler implementation of primary PCI bus Michael S. Tsirkin
@ 2013-06-20 13:11 ` Michael S. Tsirkin
  2013-06-20 13:12 ` [Qemu-devel] [PULL 21/21] pci: Fold host_buses list into PCIHostState functionality Michael S. Tsirkin
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

There are now no users of the domain field of PCIHostBus, so remove it
from the structure, and as a parameter from the pci_host_bus_register()
function which sets it.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 75513eb..9fbcdcb 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -91,7 +91,6 @@ static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
 static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
 
 struct PCIHostBus {
-    int domain;
     struct PCIBus *bus;
     QLIST_ENTRY(PCIHostBus) next;
 };
@@ -238,11 +237,10 @@ static int pcibus_reset(BusState *qbus)
     return 1;
 }
 
-static void pci_host_bus_register(int domain, PCIBus *bus)
+static void pci_host_bus_register(PCIBus *bus)
 {
     struct PCIHostBus *host;
     host = g_malloc0(sizeof(*host));
-    host->domain = domain;
     host->bus = bus;
     QLIST_INSERT_HEAD(&host_buses, host, next);
 }
@@ -303,7 +301,8 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
 
     /* host bridge */
     QLIST_INIT(&bus->child);
-    pci_host_bus_register(0, bus); /* for now only pci domain 0 is supported */
+
+    pci_host_bus_register(bus);
 
     vmstate_register(NULL, -1, &vmstate_pcibus, bus);
 }
-- 
MST

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

* [Qemu-devel] [PULL 21/21] pci: Fold host_buses list into PCIHostState functionality
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (17 preceding siblings ...)
  2013-06-20 13:11 ` [Qemu-devel] [PULL 20/21] pci: Remove domain from PCIHostBus Michael S. Tsirkin
@ 2013-06-20 13:12 ` Michael S. Tsirkin
  2013-06-20 19:02 ` [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Anthony Liguori
  2013-06-21 13:10 ` Anthony Liguori
  20 siblings, 0 replies; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-20 13:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: David Gibson

From: David Gibson <david@gibson.dropbear.id.au>

The host_buses list is an odd structure - a list of pointers to PCI root
buses existing in parallel to the normal qdev tree structure.  This patch
removes it, instead putting the link pointers into the PCIHostState
structure, which have a 1:1 relationship to PCIHostBus structures anyway.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci.c              | 33 ++++++++++++++-------------------
 include/hw/pci/pci_host.h |  2 ++
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 9fbcdcb..19c9f3c 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -90,11 +90,7 @@ static void pci_del_option_rom(PCIDevice *pdev);
 static uint16_t pci_default_sub_vendor_id = PCI_SUBVENDOR_ID_REDHAT_QUMRANET;
 static uint16_t pci_default_sub_device_id = PCI_SUBDEVICE_ID_QEMU;
 
-struct PCIHostBus {
-    struct PCIBus *bus;
-    QLIST_ENTRY(PCIHostBus) next;
-};
-static QLIST_HEAD(, PCIHostBus) host_buses;
+static QLIST_HEAD(, PCIHostState) pci_host_bridges;
 
 static const VMStateDescription vmstate_pcibus = {
     .name = "PCIBUS",
@@ -237,20 +233,19 @@ static int pcibus_reset(BusState *qbus)
     return 1;
 }
 
-static void pci_host_bus_register(PCIBus *bus)
+static void pci_host_bus_register(PCIBus *bus, DeviceState *parent)
 {
-    struct PCIHostBus *host;
-    host = g_malloc0(sizeof(*host));
-    host->bus = bus;
-    QLIST_INSERT_HEAD(&host_buses, host, next);
+    PCIHostState *host_bridge = PCI_HOST_BRIDGE(parent);
+
+    QLIST_INSERT_HEAD(&pci_host_bridges, host_bridge, next);
 }
 
 PCIBus *pci_find_primary_bus(void)
 {
     PCIBus *primary_bus = NULL;
-    struct PCIHostBus *host;
+    PCIHostState *host;
 
-    QLIST_FOREACH(host, &host_buses, next) {
+    QLIST_FOREACH(host, &pci_host_bridges, next) {
         if (primary_bus) {
             /* We have multiple root buses, refuse to select a primary */
             return NULL;
@@ -302,7 +297,7 @@ static void pci_bus_init(PCIBus *bus, DeviceState *parent,
     /* host bridge */
     QLIST_INIT(&bus->child);
 
-    pci_host_bus_register(bus);
+    pci_host_bus_register(bus, parent);
 
     vmstate_register(NULL, -1, &vmstate_pcibus, bus);
 }
@@ -1536,11 +1531,11 @@ static PciInfo *qmp_query_pci_bus(PCIBus *bus, int bus_num)
 PciInfoList *qmp_query_pci(Error **errp)
 {
     PciInfoList *info, *head = NULL, *cur_item = NULL;
-    struct PCIHostBus *host;
+    PCIHostState *host_bridge;
 
-    QLIST_FOREACH(host, &host_buses, next) {
+    QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
         info = g_malloc0(sizeof(*info));
-        info->value = qmp_query_pci_bus(host->bus, 0);
+        info->value = qmp_query_pci_bus(host_bridge->bus, 0);
 
         /* XXX: waiting for the qapi to support GSList */
         if (!cur_item) {
@@ -2204,11 +2199,11 @@ static int pci_qdev_find_recursive(PCIBus *bus,
 
 int pci_qdev_find_device(const char *id, PCIDevice **pdev)
 {
-    struct PCIHostBus *host;
+    PCIHostState *host_bridge;
     int rc = -ENODEV;
 
-    QLIST_FOREACH(host, &host_buses, next) {
-        int tmp = pci_qdev_find_recursive(host->bus, id, pdev);
+    QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
+        int tmp = pci_qdev_find_recursive(host_bridge->bus, id, pdev);
         if (!tmp) {
             rc = 0;
             break;
diff --git a/include/hw/pci/pci_host.h b/include/hw/pci/pci_host.h
index 44052f2..ba31595 100644
--- a/include/hw/pci/pci_host.h
+++ b/include/hw/pci/pci_host.h
@@ -46,6 +46,8 @@ struct PCIHostState {
     MemoryRegion mmcfg;
     uint32_t config_reg;
     PCIBus *bus;
+
+    QLIST_ENTRY(PCIHostState) next;
 };
 
 typedef struct PCIHostBridgeClass {
-- 
MST

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

* Re: [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init()
  2013-06-20 13:11 ` [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init() Michael S. Tsirkin
@ 2013-06-20 17:07   ` Richard Henderson
  0 siblings, 0 replies; 29+ messages in thread
From: Richard Henderson @ 2013-06-20 17:07 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Peter Maydell, Anthony Liguori, Stefan Weil, qemu-devel,
	Alexander Graf, Blue Swirl, Avik Sil, Andreas Färber,
	qemu-ppc, Paul Brook, Scott Wood, Paolo Bonzini, Aurelien Jarno,
	David Gibson

On 06/20/2013 06:11 AM, Michael S. Tsirkin wrote:
> From: David Gibson <david@gibson.dropbear.id.au>
> 
> At present, pci_nic_init() and pci_nic_init_nofail() assume that they will
> only create a NIC under the primary PCI root.  As we add support for
> multiple PCI roots, that may no longer be the case.  This patch adds a root
> bus parameter to pci_nic_init() (and updates callers accordingly) to allow
> the machine init code using it to specify the right PCI root for NICs
> created by old-style -net nic parameters.  NICs created new-style, with
> -device can of course be put anywhere.
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  hw/alpha/dp264.c         |  2 +-
>  hw/arm/realview.c        |  6 ++++--
>  hw/arm/versatilepb.c     |  2 +-
>  hw/i386/pc.c             |  2 +-
>  hw/mips/mips_fulong2e.c  |  6 +++---
>  hw/mips/mips_malta.c     |  6 +++---
>  hw/pci/pci-hotplug-old.c |  3 ++-
>  hw/pci/pci.c             | 10 ++++++----
>  hw/ppc/e500.c            |  2 +-
>  hw/ppc/mac_newworld.c    |  2 +-
>  hw/ppc/mac_oldworld.c    |  2 +-
>  hw/ppc/ppc440_bamboo.c   |  2 +-
>  hw/ppc/prep.c            |  2 +-
>  hw/ppc/spapr.c           |  2 +-
>  hw/sh4/r2d.c             |  5 ++++-
>  hw/sparc64/sun4u.c       |  2 +-
>  include/hw/pci/pci.h     |  6 ++++--
>  17 files changed, 36 insertions(+), 26 deletions(-)

Acked-by: Richard Henderson <rth@twiddle.net>


r~

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (18 preceding siblings ...)
  2013-06-20 13:12 ` [Qemu-devel] [PULL 21/21] pci: Fold host_buses list into PCIHostState functionality Michael S. Tsirkin
@ 2013-06-20 19:02 ` Anthony Liguori
  2013-06-20 20:34   ` Gleb Natapov
  2013-06-21 13:10 ` Anthony Liguori
  20 siblings, 1 reply; 29+ messages in thread
From: Anthony Liguori @ 2013-06-20 19:02 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: peter.maydell, drjones, Gleb Natapov, stefano.stabellini,
	haoyu.zhang, Paul.Durrant, Paolo Bonzini, akong, lersek, david

"Michael S. Tsirkin" <mst@redhat.com> writes:

> From: Michael S. Tsirkin <mst@redhat.com>
>
> The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
>
>   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
>
> are available in the git repository at:
>
>   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
>
> for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
>
>   pci: Fold host_buses list into PCIHostState functionality (2013-06-19 18:35:05 +0300)
>
> ----------------------------------------------------------------
> pci,net,misc enhancements

I don't like the amount of "misc" in this pull request but I'll take it
with appropriate acks.

>
> This includes some pci and net-related enhancements:
>
> Better support for systems with multiple PCI root buses
> A new management interface for access to rx filter in NICs
> KVM Speedup for MSI updates on kvm
> FW cfg interface for more robust pci programming in BIOS
> Minor fixes/cleanups for fw cfg and cross-version migration -
>     because of dependencies with other patches
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------
> Amos Kong (1):
>       net: add support of mac-programming over macvtap in QEMU side
>
> Andrew Jones (1):
>       e1000: cleanup process_tx_desc
>
> David Gibson (10):
>       pci: Cleanup configuration for pci-hotplug.c
>       pci: Move pci_read_devaddr to pci-hotplug-old.c
>       pci: Abolish pci_find_root_bus()
>       pci: Use helper to find device's root bus in pci_find_domain()
>       pci: Replace pci_find_domain() with more general pci_root_bus_path()
>       pci: Add root bus argument to pci_get_bus_devfn()
>       pci: Add root bus parameter to pci_nic_init()
>       pci: Simpler implementation of primary PCI bus
>       pci: Remove domain from PCIHostBus
>       pci: Fold host_buses list into PCIHostState functionality
>
> Michael S. Tsirkin (9):
>       range: add Range structure
>       pci: store PCI hole ranges in guestinfo structure
>       pc: pass PCI hole ranges to Guests
>       pc_piix: cleanup init compat handling
>       kvm: zero-initialize KVM_SET_GSI_ROUTING input
>       kvm: skip system call when msi route is unchanged
>       MAINTAINERS: s/Marcelo/Paolo/

Shouldn't these be coming through the uq/master tree?  I haven't see a
pull for uq/master in a long time.  Does that tree still exist?

Would that be coming from Paolo or Gleb?  Can one of ya'll ack these
changes please.

Regards,

Anthony Liguori

>       pvpanic: initialization cleanup
>       pvpanic: fix fwcfg for big endian hosts
>
>  MAINTAINERS                                 |   2 +-
>  QMP/qmp-events.txt                          |  17 ++++
>  default-configs/i386-softmmu.mak            |   3 +-
>  default-configs/ppc64-softmmu.mak           |   2 -
>  default-configs/x86_64-softmmu.mak          |   3 +-
>  hmp-commands.hx                             |   4 +-
>  hw/alpha/dp264.c                            |   2 +-
>  hw/arm/realview.c                           |   6 +-
>  hw/arm/versatilepb.c                        |   2 +-
>  hw/i386/pc.c                                |  74 ++++++++++++++-
>  hw/i386/pc_piix.c                           |  40 +++++---
>  hw/i386/pc_q35.c                            |  18 +++-
>  hw/mips/mips_fulong2e.c                     |   6 +-
>  hw/mips/mips_malta.c                        |   6 +-
>  hw/misc/pvpanic.c                           |  31 ++++---
>  hw/net/e1000.c                              |  18 ++--
>  hw/net/virtio-net.c                         | 111 ++++++++++++++++++++++
>  hw/pci-host/piix.c                          |   9 ++
>  hw/pci-host/q35.c                           |  17 ++++
>  hw/pci/Makefile.objs                        |   2 +-
>  hw/pci/{pci-hotplug.c => pci-hotplug-old.c} |  75 ++++++++++++---
>  hw/pci/pci.c                                | 137 ++++++++++++++--------------
>  hw/pci/pci_host.c                           |   1 +
>  hw/pci/pcie_aer.c                           |   9 +-
>  hw/ppc/e500.c                               |   2 +-
>  hw/ppc/mac_newworld.c                       |   2 +-
>  hw/ppc/mac_oldworld.c                       |   2 +-
>  hw/ppc/ppc440_bamboo.c                      |   2 +-
>  hw/ppc/prep.c                               |   2 +-
>  hw/ppc/spapr.c                              |   2 +-
>  hw/ppc/spapr_pci.c                          |  10 ++
>  hw/sh4/r2d.c                                |   5 +-
>  hw/sparc64/sun4u.c                          |   2 +-
>  include/hw/i386/pc.h                        |  22 ++++-
>  include/hw/pci-host/q35.h                   |   2 +
>  include/hw/pci/pci.h                        |  17 ++--
>  include/hw/pci/pci_host.h                   |  12 +++
>  include/monitor/monitor.h                   |   1 +
>  include/net/net.h                           |   3 +
>  include/qemu/range.h                        |  16 ++++
>  include/qemu/typedefs.h                     |   1 +
>  kvm-all.c                                   |  23 +++--
>  monitor.c                                   |   1 +
>  net/net.c                                   |  47 ++++++++++
>  qapi-schema.json                            |  75 +++++++++++++++
>  qmp-commands.hx                             |  63 +++++++++++++
>  46 files changed, 733 insertions(+), 174 deletions(-)
>  rename hw/pci/{pci-hotplug.c => pci-hotplug-old.c} (78%)

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-20 19:02 ` [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Anthony Liguori
@ 2013-06-20 20:34   ` Gleb Natapov
  2013-06-20 20:46     ` Anthony Liguori
  0 siblings, 1 reply; 29+ messages in thread
From: Gleb Natapov @ 2013-06-20 20:34 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: peter.maydell, drjones, Michael S. Tsirkin, haoyu.zhang,
	stefano.stabellini, qemu-devel, Paul.Durrant, Paolo Bonzini,
	akong, lersek, david

On Thu, Jun 20, 2013 at 02:02:59PM -0500, Anthony Liguori wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > From: Michael S. Tsirkin <mst@redhat.com>
> >
> > The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
> >
> >   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
> >
> > are available in the git repository at:
> >
> >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
> >
> > for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
> >
> >   pci: Fold host_buses list into PCIHostState functionality (2013-06-19 18:35:05 +0300)
> >
> > ----------------------------------------------------------------
> > pci,net,misc enhancements
> 
> I don't like the amount of "misc" in this pull request but I'll take it
> with appropriate acks.
> 
> >
> > This includes some pci and net-related enhancements:
> >
> > Better support for systems with multiple PCI root buses
> > A new management interface for access to rx filter in NICs
> > KVM Speedup for MSI updates on kvm
> > FW cfg interface for more robust pci programming in BIOS
> > Minor fixes/cleanups for fw cfg and cross-version migration -
> >     because of dependencies with other patches
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >
> > ----------------------------------------------------------------
> > Amos Kong (1):
> >       net: add support of mac-programming over macvtap in QEMU side
> >
> > Andrew Jones (1):
> >       e1000: cleanup process_tx_desc
> >
> > David Gibson (10):
> >       pci: Cleanup configuration for pci-hotplug.c
> >       pci: Move pci_read_devaddr to pci-hotplug-old.c
> >       pci: Abolish pci_find_root_bus()
> >       pci: Use helper to find device's root bus in pci_find_domain()
> >       pci: Replace pci_find_domain() with more general pci_root_bus_path()
> >       pci: Add root bus argument to pci_get_bus_devfn()
> >       pci: Add root bus parameter to pci_nic_init()
> >       pci: Simpler implementation of primary PCI bus
> >       pci: Remove domain from PCIHostBus
> >       pci: Fold host_buses list into PCIHostState functionality
> >
> > Michael S. Tsirkin (9):
> >       range: add Range structure
> >       pci: store PCI hole ranges in guestinfo structure
> >       pc: pass PCI hole ranges to Guests
> >       pc_piix: cleanup init compat handling
> >       kvm: zero-initialize KVM_SET_GSI_ROUTING input
> >       kvm: skip system call when msi route is unchanged
> >       MAINTAINERS: s/Marcelo/Paolo/
> 
> Shouldn't these be coming through the uq/master tree?  I haven't see a
> pull for uq/master in a long time.  Does that tree still exist?
> 
> Would that be coming from Paolo or Gleb?  Can one of ya'll ack these
> changes please.
> 
ACK. I should have taken it through KVM tree really, but since MST's
patch sending scripts depend on accurate MAINTAINERS information having
it in his tree saved Marcelo's inbox from a couple of dozens unwanted
emails.

--
			Gleb.

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-20 20:34   ` Gleb Natapov
@ 2013-06-20 20:46     ` Anthony Liguori
  0 siblings, 0 replies; 29+ messages in thread
From: Anthony Liguori @ 2013-06-20 20:46 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: peter.maydell, drjones, Michael S. Tsirkin, haoyu.zhang,
	stefano.stabellini, qemu-devel, Paul.Durrant, Paolo Bonzini,
	akong, lersek, david

Gleb Natapov <gleb@redhat.com> writes:

> On Thu, Jun 20, 2013 at 02:02:59PM -0500, Anthony Liguori wrote:
>> "Michael S. Tsirkin" <mst@redhat.com> writes:
>> 
>> > From: Michael S. Tsirkin <mst@redhat.com>
>> >
>> > The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
>> >
>> >   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
>> >
>> > are available in the git repository at:
>> >
>> >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
>> >
>> > for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
>> >
>> >   pci: Fold host_buses list into PCIHostState functionality (2013-06-19 18:35:05 +0300)
>> >
>> > ----------------------------------------------------------------
>> > pci,net,misc enhancements
>> 
>> I don't like the amount of "misc" in this pull request but I'll take it
>> with appropriate acks.
>> 
>> >
>> > This includes some pci and net-related enhancements:
>> >
>> > Better support for systems with multiple PCI root buses
>> > A new management interface for access to rx filter in NICs
>> > KVM Speedup for MSI updates on kvm
>> > FW cfg interface for more robust pci programming in BIOS
>> > Minor fixes/cleanups for fw cfg and cross-version migration -
>> >     because of dependencies with other patches
>> >
>> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> >
>> > ----------------------------------------------------------------
>> > Amos Kong (1):
>> >       net: add support of mac-programming over macvtap in QEMU side
>> >
>> > Andrew Jones (1):
>> >       e1000: cleanup process_tx_desc
>> >
>> > David Gibson (10):
>> >       pci: Cleanup configuration for pci-hotplug.c
>> >       pci: Move pci_read_devaddr to pci-hotplug-old.c
>> >       pci: Abolish pci_find_root_bus()
>> >       pci: Use helper to find device's root bus in pci_find_domain()
>> >       pci: Replace pci_find_domain() with more general pci_root_bus_path()
>> >       pci: Add root bus argument to pci_get_bus_devfn()
>> >       pci: Add root bus parameter to pci_nic_init()
>> >       pci: Simpler implementation of primary PCI bus
>> >       pci: Remove domain from PCIHostBus
>> >       pci: Fold host_buses list into PCIHostState functionality
>> >
>> > Michael S. Tsirkin (9):
>> >       range: add Range structure
>> >       pci: store PCI hole ranges in guestinfo structure
>> >       pc: pass PCI hole ranges to Guests
>> >       pc_piix: cleanup init compat handling
>> >       kvm: zero-initialize KVM_SET_GSI_ROUTING input
>> >       kvm: skip system call when msi route is unchanged
>> >       MAINTAINERS: s/Marcelo/Paolo/
>> 
>> Shouldn't these be coming through the uq/master tree?  I haven't see a
>> pull for uq/master in a long time.  Does that tree still exist?
>> 
>> Would that be coming from Paolo or Gleb?  Can one of ya'll ack these
>> changes please.
>> 
> ACK. I should have taken it through KVM tree really, but since MST's
> patch sending scripts depend on accurate MAINTAINERS information having
> it in his tree saved Marcelo's inbox from a couple of dozens unwanted
> emails.

Thanks.

Regards,

Anthony Liguori

>
> --
> 			Gleb.

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
                   ` (19 preceding siblings ...)
  2013-06-20 19:02 ` [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Anthony Liguori
@ 2013-06-21 13:10 ` Anthony Liguori
  2013-06-23 11:38   ` Michael S. Tsirkin
  20 siblings, 1 reply; 29+ messages in thread
From: Anthony Liguori @ 2013-06-21 13:10 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: peter.maydell, drjones, stefano.stabellini, haoyu.zhang,
	Paul.Durrant, akong, lersek, david

"Michael S. Tsirkin" <mst@redhat.com> writes:

> From: Michael S. Tsirkin <mst@redhat.com>
>
> The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
>
>   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
>
> are available in the git repository at:
>
>   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
>
> for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
>
>   pci: Fold host_buses list into PCIHostState functionality
>   (2013-06-19 18:35:05 +0300)

SEGV's during pretty much any test I try to run during startup:

Core was generated by `/home/aliguori/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel /usr/local/'.
Program terminated with signal 11, Segmentation fault.
#0  qemu_get_queue (nic=0x0) at /home/aliguori/git/qemu/net/net.c:263

warning: Source file is more recent than executable.
263	    return qemu_get_subqueue(nic, 0);
(gdb) bt
#0  qemu_get_queue (nic=0x0) at /home/aliguori/git/qemu/net/net.c:263
#1  0x00007f2d73fb2902 in virtio_net_device_init (vdev=0x7f2d75aeafe0)
    at /home/aliguori/git/qemu/hw/net/virtio-net.c:1484
#2  0x00007f2d73fbb426 in virtio_device_init (qdev=0x7f2d75aeafe0)
    at /home/aliguori/git/qemu/hw/virtio/virtio.c:1113
#3  0x00007f2d73e421c1 in device_realize (dev=0x7f2d75aeafe0, err=
    0x7fff85322420) at /home/aliguori/git/qemu/hw/core/qdev.c:178
#4  0x00007f2d73e43863 in device_set_realized (obj=0x7f2d75aeafe0, value=true, 
    err=0x7fff85322530) at /home/aliguori/git/qemu/hw/core/qdev.c:699
#5  0x00007f2d73f29a2e in property_set_bool (obj=0x7f2d75aeafe0, 
    v=<optimized out>, opaque=0x7f2d75af5b60, name=<optimized out>, errp=
    0x7fff85322530) at /home/aliguori/git/qemu/qom/object.c:1301
#6  0x00007f2d73f2c8e5 in object_property_set_qobject (obj=0x7f2d75aeafe0, 
    value=<optimized out>, name=0x7f2d740a4763 "realized", errp=0x7fff85322530)
    at /home/aliguori/git/qemu/qom/qom-qobject.c:24
#7  0x00007f2d73f2b6fe in object_property_set_bool (obj=obj@entry=
    0x7f2d75aeafe0, value=value@entry=true, name=name@entry=
    0x7f2d740a4763 "realized", errp=errp@entry=0x7fff85322530)
    at /home/aliguori/git/qemu/qom/object.c:852
#8  0x00007f2d73e427aa in qdev_init (dev=dev@entry=0x7f2d75aeafe0)
    at /home/aliguori/git/qemu/hw/core/qdev.c:163
#9  0x00007f2d73ee0079 in virtio_net_pci_init (vpci_dev=0x7f2d75aea790)
    at /home/aliguori/git/qemu/hw/virtio/virtio-pci.c:1403
---Type <return> to continue, or q <return> to quit---
#10 0x00007f2d73ee08af in virtio_pci_init (pci_dev=<optimized out>)
    at /home/aliguori/git/qemu/hw/virtio/virtio-pci.c:990
#11 0x00007f2d73e9706d in pci_qdev_init (qdev=0x7f2d75aea790)
    at /home/aliguori/git/qemu/hw/pci/pci.c:1717
#12 0x00007f2d73e421c1 in device_realize (dev=0x7f2d75aea790, err=
    0x7fff853226a0) at /home/aliguori/git/qemu/hw/core/qdev.c:178
#13 0x00007f2d73e43863 in device_set_realized (obj=0x7f2d75aea790, value=true, 
    err=0x7fff853227b0) at /home/aliguori/git/qemu/hw/core/qdev.c:699
#14 0x00007f2d73f29a2e in property_set_bool (obj=0x7f2d75aea790, 
    v=<optimized out>, opaque=0x7f2d75aed210, name=<optimized out>, errp=
    0x7fff853227b0) at /home/aliguori/git/qemu/qom/object.c:1301
#15 0x00007f2d73f2c8e5 in object_property_set_qobject (obj=0x7f2d75aea790, 
    value=<optimized out>, name=0x7f2d740a4763 "realized", errp=0x7fff853227b0)
    at /home/aliguori/git/qemu/qom/qom-qobject.c:24
#16 0x00007f2d73f2b6fe in object_property_set_bool (obj=obj@entry=
    0x7f2d75aea790, value=value@entry=true, name=name@entry=
    0x7f2d740a4763 "realized", errp=errp@entry=0x7fff853227b0)
    at /home/aliguori/git/qemu/qom/object.c:852
#17 0x00007f2d73e427aa in qdev_init (dev=dev@entry=0x7f2d75aea790)
    at /home/aliguori/git/qemu/hw/core/qdev.c:163
#18 0x00007f2d73f12f97 in qdev_device_add (opts=opts@entry=0x7f2d75aea5d0)
    at /home/aliguori/git/qemu/qdev-monitor.c:497
#19 0x00007f2d73f1339a in do_device_add (mon=<optimized out>, 
---Type <return> to continue, or q <return> to quit---
    qdict=<optimized out>, ret_data=<optimized out>)
    at /home/aliguori/git/qemu/qdev-monitor.c:609
#20 0x00007f2d73fd0568 in qmp_call_cmd (cmd=<optimized out>, params=
    0x7f2d75ae9380, mon=0x7f2d75a7a600)
    at /home/aliguori/git/qemu/monitor.c:4497
#21 handle_qmp_command (parser=<optimized out>, tokens=<optimized out>)
    at /home/aliguori/git/qemu/monitor.c:4563
#22 0x00007f2d740794ba in json_message_process_token (lexer=0x7f2d75a7a6b0, 
    token=0x7f2d75b47720, type=JSON_OPERATOR, x=129, y=0)
    at /home/aliguori/git/qemu/qobject/json-streamer.c:87
#23 0x00007f2d7408b9cf in json_lexer_feed_char (lexer=lexer@entry=
    0x7f2d75a7a6b0, ch=125 '}', flush=flush@entry=false)
    at /home/aliguori/git/qemu/qobject/json-lexer.c:303
#24 0x00007f2d7408bb16 in json_lexer_feed (lexer=0x7f2d75a7a6b0, 
    buffer=<optimized out>, size=<optimized out>)
    at /home/aliguori/git/qemu/qobject/json-lexer.c:356
#25 0x00007f2d740796d1 in json_message_parser_feed (parser=<optimized out>, 
    buffer=<optimized out>, size=<optimized out>)
    at /home/aliguori/git/qemu/qobject/json-streamer.c:110
#26 0x00007f2d73fceafb in monitor_control_read (opaque=<optimized out>, 
    buf=<optimized out>, size=<optimized out>)
    at /home/aliguori/git/qemu/monitor.c:4584
#27 0x00007f2d73f16381 in qemu_chr_be_write (len=<optimized out>, buf=
---Type <return> to continue, or q <return> to quit---
    0x7fff85322b20 "}\n", s=0x7f2d75a71a00)
    at /home/aliguori/git/qemu/qemu-char.c:165
#28 tcp_chr_read (chan=<optimized out>, cond=<optimized out>, opaque=
    0x7f2d75a71a00) at /home/aliguori/git/qemu/qemu-char.c:2467
#29 0x00007f2d73405a55 in g_main_context_dispatch ()
   from /lib64/libglib-2.0.so.0
#30 0x00007f2d73eec438 in glib_pollfds_poll ()
    at /home/aliguori/git/qemu/main-loop.c:188
#31 os_host_main_loop_wait (timeout=<optimized out>)
    at /home/aliguori/git/qemu/main-loop.c:233
#32 main_loop_wait (nonblocking=<optimized out>)
    at /home/aliguori/git/qemu/main-loop.c:465
#33 0x00007f2d73da35a1 in main_loop () at /home/aliguori/git/qemu/vl.c:2028
#34 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>)
    at /home/aliguori/git/qemu/vl.c:4386



>
> ----------------------------------------------------------------
> pci,net,misc enhancements
>
> This includes some pci and net-related enhancements:
>
> Better support for systems with multiple PCI root buses
> A new management interface for access to rx filter in NICs
> KVM Speedup for MSI updates on kvm
> FW cfg interface for more robust pci programming in BIOS
> Minor fixes/cleanups for fw cfg and cross-version migration -
>     because of dependencies with other patches
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------
> Amos Kong (1):
>       net: add support of mac-programming over macvtap in QEMU side
>
> Andrew Jones (1):
>       e1000: cleanup process_tx_desc
>
> David Gibson (10):
>       pci: Cleanup configuration for pci-hotplug.c
>       pci: Move pci_read_devaddr to pci-hotplug-old.c
>       pci: Abolish pci_find_root_bus()
>       pci: Use helper to find device's root bus in pci_find_domain()
>       pci: Replace pci_find_domain() with more general pci_root_bus_path()
>       pci: Add root bus argument to pci_get_bus_devfn()
>       pci: Add root bus parameter to pci_nic_init()
>       pci: Simpler implementation of primary PCI bus
>       pci: Remove domain from PCIHostBus
>       pci: Fold host_buses list into PCIHostState functionality
>
> Michael S. Tsirkin (9):
>       range: add Range structure
>       pci: store PCI hole ranges in guestinfo structure
>       pc: pass PCI hole ranges to Guests
>       pc_piix: cleanup init compat handling
>       kvm: zero-initialize KVM_SET_GSI_ROUTING input
>       kvm: skip system call when msi route is unchanged
>       MAINTAINERS: s/Marcelo/Paolo/
>       pvpanic: initialization cleanup
>       pvpanic: fix fwcfg for big endian hosts
>
>  MAINTAINERS                                 |   2 +-
>  QMP/qmp-events.txt                          |  17 ++++
>  default-configs/i386-softmmu.mak            |   3 +-
>  default-configs/ppc64-softmmu.mak           |   2 -
>  default-configs/x86_64-softmmu.mak          |   3 +-
>  hmp-commands.hx                             |   4 +-
>  hw/alpha/dp264.c                            |   2 +-
>  hw/arm/realview.c                           |   6 +-
>  hw/arm/versatilepb.c                        |   2 +-
>  hw/i386/pc.c                                |  74 ++++++++++++++-
>  hw/i386/pc_piix.c                           |  40 +++++---
>  hw/i386/pc_q35.c                            |  18 +++-
>  hw/mips/mips_fulong2e.c                     |   6 +-
>  hw/mips/mips_malta.c                        |   6 +-
>  hw/misc/pvpanic.c                           |  31 ++++---
>  hw/net/e1000.c                              |  18 ++--
>  hw/net/virtio-net.c                         | 111 ++++++++++++++++++++++
>  hw/pci-host/piix.c                          |   9 ++
>  hw/pci-host/q35.c                           |  17 ++++
>  hw/pci/Makefile.objs                        |   2 +-
>  hw/pci/{pci-hotplug.c => pci-hotplug-old.c} |  75 ++++++++++++---
>  hw/pci/pci.c                                | 137 ++++++++++++++--------------
>  hw/pci/pci_host.c                           |   1 +
>  hw/pci/pcie_aer.c                           |   9 +-
>  hw/ppc/e500.c                               |   2 +-
>  hw/ppc/mac_newworld.c                       |   2 +-
>  hw/ppc/mac_oldworld.c                       |   2 +-
>  hw/ppc/ppc440_bamboo.c                      |   2 +-
>  hw/ppc/prep.c                               |   2 +-
>  hw/ppc/spapr.c                              |   2 +-
>  hw/ppc/spapr_pci.c                          |  10 ++
>  hw/sh4/r2d.c                                |   5 +-
>  hw/sparc64/sun4u.c                          |   2 +-
>  include/hw/i386/pc.h                        |  22 ++++-
>  include/hw/pci-host/q35.h                   |   2 +
>  include/hw/pci/pci.h                        |  17 ++--
>  include/hw/pci/pci_host.h                   |  12 +++
>  include/monitor/monitor.h                   |   1 +
>  include/net/net.h                           |   3 +
>  include/qemu/range.h                        |  16 ++++
>  include/qemu/typedefs.h                     |   1 +
>  kvm-all.c                                   |  23 +++--
>  monitor.c                                   |   1 +
>  net/net.c                                   |  47 ++++++++++
>  qapi-schema.json                            |  75 +++++++++++++++
>  qmp-commands.hx                             |  63 +++++++++++++
>  46 files changed, 733 insertions(+), 174 deletions(-)
>  rename hw/pci/{pci-hotplug.c => pci-hotplug-old.c} (78%)

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-21 13:10 ` Anthony Liguori
@ 2013-06-23 11:38   ` Michael S. Tsirkin
  2013-06-24  6:43     ` Amos Kong
  0 siblings, 1 reply; 29+ messages in thread
From: Michael S. Tsirkin @ 2013-06-23 11:38 UTC (permalink / raw)
  To: Anthony Liguori
  Cc: peter.maydell, drjones, stefano.stabellini, haoyu.zhang,
	qemu-devel, Paul.Durrant, akong, lersek, david

On Fri, Jun 21, 2013 at 08:10:15AM -0500, Anthony Liguori wrote:
> "Michael S. Tsirkin" <mst@redhat.com> writes:
> 
> > From: Michael S. Tsirkin <mst@redhat.com>
> >
> > The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
> >
> >   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
> >
> > are available in the git repository at:
> >
> >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
> >
> > for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
> >
> >   pci: Fold host_buses list into PCIHostState functionality
> >   (2013-06-19 18:35:05 +0300)
> 
> SEGV's during pretty much any test I try to run during startup:
> 
> Core was generated by `/home/aliguori/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel /usr/local/'.
> Program terminated with signal 11, Segmentation fault.
> #0  qemu_get_queue (nic=0x0) at /home/aliguori/git/qemu/net/net.c:263


It's caused by the rx filter patch, sorry about not catching it.
I've fixed it up but will send a pull request without it,
so it can get a bit more testing.


-- 
MST

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

* Re: [Qemu-devel] [PULL 00/21] pci,net,misc enhancements
  2013-06-23 11:38   ` Michael S. Tsirkin
@ 2013-06-24  6:43     ` Amos Kong
  0 siblings, 0 replies; 29+ messages in thread
From: Amos Kong @ 2013-06-24  6:43 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: peter.maydell, drjones, stefano.stabellini, haoyu.zhang,
	qemu-devel, Paul.Durrant, Anthony Liguori, lersek, david

On Sun, Jun 23, 2013 at 02:38:04PM +0300, Michael S. Tsirkin wrote:
> On Fri, Jun 21, 2013 at 08:10:15AM -0500, Anthony Liguori wrote:
> > "Michael S. Tsirkin" <mst@redhat.com> writes:
> > 
> > > From: Michael S. Tsirkin <mst@redhat.com>
> > >
> > > The following changes since commit 90a2541b763b31d2b551b07e24aae3de5266d31b:
> > >
> > >   target-i386: fix over 80 chars warnings (2013-06-15 17:50:38 +0000)
> > >
> > > are available in the git repository at:
> > >
> > >   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
> > >
> > > for you to fetch changes up to f96c30047009f8a9c3cecf68104d8d99f989f54d:
> > >
> > >   pci: Fold host_buses list into PCIHostState functionality
> > >   (2013-06-19 18:35:05 +0300)
> > 
> > SEGV's during pretty much any test I try to run during startup:
> > 
> > Core was generated by `/home/aliguori/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel /usr/local/'.
> > Program terminated with signal 11, Segmentation fault.
> > #0  qemu_get_queue (nic=0x0) at /home/aliguori/git/qemu/net/net.c:263
> 
> 
> It's caused by the rx filter patch, sorry about not catching it.

If we don't assign 'id' for virtio-net nic device, crash[1] will occur.
Your fix is right for that.

But anthony's calltrace seems different from that.

> I've fixed it up but will send a pull request without it,
> so it can get a bit more testing.

BTW, we can use 'nc->name' to avoid the rx-filter crash[1].
I have sent a patch for mst/pci.

-- 
			Amos.

crash [1]

#0  0x00007ffff59236b1 in __strlen_sse2_pminub () from /lib64/libc.so.6
#1  0x0000555555873a8d in qstring_from_str (str=0x0) at qobject/qstring.c:72
#2  0x0000555555876dae in parse_escape (ap=0x7ffff1c3c910, ctxt=0x7fffe4015650) at qobject/json-parser.c:614
#3  parse_value (ctxt=ctxt@entry=0x7fffe4015650, ap=ap@entry=0x7ffff1c3c910) at qobject/json-parser.c:691
#4  0x0000555555876fd2 in parse_pair (ctxt=ctxt@entry=0x7fffe4015650, dict=dict@entry=0x7fffe4032400, ap=ap@entry=0x7ffff1c3c910) at qobject/json-parser.c:393
#5  0x00005555558765fe in parse_object (ap=0x7ffff1c3c910, ctxt=0x7fffe4015650) at qobject/json-parser.c:454
#6  parse_value (ctxt=ctxt@entry=0x7fffe4015650, ap=ap@entry=0x7ffff1c3c910) at qobject/json-parser.c:686
#7  0x0000555555877193 in json_parser_parse_err (tokens=<optimized out>, ap=0x7ffff1c3c910, errp=errp@entry=0x0) at qobject/json-parser.c:717
#8  0x000055555587729f in json_parser_parse (tokens=<optimized out>, ap=<optimized out>) at qobject/json-parser.c:705
#9  0x0000555555875254 in parse_json (parser=0x7ffff1c3c8a0, tokens=<optimized out>) at qobject/qjson.c:34
#10 0x0000555555875d6a in json_message_process_token (lexer=0x7ffff1c3c8a8, token=0x7fffe4015440, type=JSON_OPERATOR, x=26, y=0) at qobject/json-streamer.c:87
#11 0x000055555588a7af in json_lexer_feed_char (lexer=lexer@entry=0x7ffff1c3c8a8, ch=125 '}', flush=flush@entry=false) at qobject/json-lexer.c:303
#12 0x000055555588a8f6 in json_lexer_feed (lexer=lexer@entry=0x7ffff1c3c8a8, buffer=buffer@entry=0x5555558d1882 "{ 'name': %s, 'path': %s }", size=<optimized out>)
    at qobject/json-lexer.c:356
#13 0x0000555555875f81 in json_message_parser_feed (parser=parser@entry=0x7ffff1c3c8a0, buffer=buffer@entry=0x5555558d1882 "{ 'name': %s, 'path': %s }", size=<optimized out>)
    at qobject/json-streamer.c:110
#14 0x0000555555875a2d in qobject_from_jsonv (string=0x5555558d1882 "{ 'name': %s, 'path': %s }", ap=ap@entry=0x7ffff1c3c910) at qobject/qjson.c:44
#15 0x0000555555875b39 in qobject_from_jsonf (string=string@entry=0x5555558d1882 "{ 'name': %s, 'path': %s }") at qobject/qjson.c:66
#16 0x00005555557b5477 in rxfilter_notify (nc=nc@entry=0x5555567463e0) at /home/devel/qemu/hw/net/virtio-net.c:203
#17 0x00005555557b6fbe in virtio_net_handle_rx_mode (iov_cnt=<optimized out>, iov=0x7ffff1c44ab0, cmd=0 '\000', n=0x555556756528) at /home/devel/qemu/hw/net/virtio-net.c:542
#18 virtio_net_handle_ctrl (vdev=0x555556756528, vq=0x555556767850) at /home/devel/qemu/hw/net/virtio-net.c:755
#19 0x00005555557c7cf2 in access_with_adjusted_size (addr=addr@entry=16, value=value@entry=0x7ffff1c48b68, size=2, access_size_min=<optimized out>, 
    access_size_max=<optimized out>, access=access@entry=0x5555557c8310 <memory_region_write_accessor>, opaque=opaque@entry=0x5555567563e0) at /home/devel/qemu/memory.c:399
#20 0x00005555557c93d7 in memory_region_iorange_write (iorange=<optimized out>, offset=16, width=2, data=2) at /home/devel/qemu/memory.c:475
#21 0x00005555557c6a16 in kvm_handle_io (count=1, size=2, direction=1, data=<optimized out>, port=49232) at /home/devel/qemu/kvm-all.c:1510
#22 kvm_cpu_exec (env=env@entry=0x5555566d6660) at /home/devel/qemu/kvm-all.c:1659
#23 0x00005555557706d5 in qemu_kvm_cpu_thread_fn (arg=0x5555566d6660) at /home/devel/qemu/cpus.c:759
#24 0x00007ffff6985d15 in start_thread () from /lib64/libpthread.so.0
#25 0x00007ffff58b548d in clone () from /lib64/libc.so.6

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

end of thread, other threads:[~2013-06-24  6:44 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-20 13:08 [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Michael S. Tsirkin
2013-06-20 13:08 ` [Qemu-devel] [PULL 01/21] range: add Range structure Michael S. Tsirkin
2013-06-20 13:08 ` [Qemu-devel] [PULL 03/21] pc: pass PCI hole ranges to Guests Michael S. Tsirkin
2013-06-20 13:08 ` [Qemu-devel] [PULL 04/21] pc_piix: cleanup init compat handling Michael S. Tsirkin
2013-06-20 13:10 ` [Qemu-devel] [PULL 05/21] e1000: cleanup process_tx_desc Michael S. Tsirkin
2013-06-20 13:10 ` [PULL 06/21] kvm: zero-initialize KVM_SET_GSI_ROUTING input Michael S. Tsirkin
2013-06-20 13:10   ` [Qemu-devel] " Michael S. Tsirkin
2013-06-20 13:10 ` [PULL 07/21] kvm: skip system call when msi route is unchanged Michael S. Tsirkin
2013-06-20 13:10   ` [Qemu-devel] " Michael S. Tsirkin
2013-06-20 13:10 ` [Qemu-devel] [PULL 08/21] MAINTAINERS: s/Marcelo/Paolo/ Michael S. Tsirkin
2013-06-20 13:10 ` [Qemu-devel] [PULL 09/21] pvpanic: initialization cleanup Michael S. Tsirkin
2013-06-20 13:10 ` [Qemu-devel] [PULL 10/21] pvpanic: fix fwcfg for big endian hosts Michael S. Tsirkin
2013-06-20 13:10 ` [Qemu-devel] [PULL 11/21] net: add support of mac-programming over macvtap in QEMU side Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 13/21] pci: Move pci_read_devaddr to pci-hotplug-old.c Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 14/21] pci: Abolish pci_find_root_bus() Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 15/21] pci: Use helper to find device's root bus in pci_find_domain() Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 16/21] pci: Replace pci_find_domain() with more general pci_root_bus_path() Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 17/21] pci: Add root bus argument to pci_get_bus_devfn() Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 18/21] pci: Add root bus parameter to pci_nic_init() Michael S. Tsirkin
2013-06-20 17:07   ` Richard Henderson
2013-06-20 13:11 ` [Qemu-devel] [PULL 19/21] pci: Simpler implementation of primary PCI bus Michael S. Tsirkin
2013-06-20 13:11 ` [Qemu-devel] [PULL 20/21] pci: Remove domain from PCIHostBus Michael S. Tsirkin
2013-06-20 13:12 ` [Qemu-devel] [PULL 21/21] pci: Fold host_buses list into PCIHostState functionality Michael S. Tsirkin
2013-06-20 19:02 ` [Qemu-devel] [PULL 00/21] pci,net,misc enhancements Anthony Liguori
2013-06-20 20:34   ` Gleb Natapov
2013-06-20 20:46     ` Anthony Liguori
2013-06-21 13:10 ` Anthony Liguori
2013-06-23 11:38   ` Michael S. Tsirkin
2013-06-24  6:43     ` Amos Kong

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.