All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05
@ 2017-05-05 10:13 Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 01/21] hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support Paolo Bonzini
                   ` (22 more replies)
  0 siblings, 23 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit e619b14746e5d8c0e53061661fd0e1da01fd4d60:

  Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging (2017-05-02 15:16:29 +0100)

are available in the git repository at:

  git://github.com/bonzini/qemu.git tags/for-upstream

for you to fetch changes up to 95615ce5a1beffff1a5dd3597d8cb6ba83f0010e:

  vhost-scsi: create a vhost-scsi-common abstraction (2017-05-05 12:10:00 +0200)

----------------------------------------------------------------
A large set of small patches.  I have not included yet vhost-user-scsi,
but it'll come in the next pull request.

* use GDB XML register description for x86
* use _Static_assert in QEMU_BUILD_BUG_ON
* add "R:" to MAINTAINERS and get_maintainers
* checkpatch improvements
* dump threading fixes
* first part of vhost-user-scsi support
* QemuMutex tracing
* vmw_pvscsi and megasas fixes
* sgabios module update
* use Rev3 (ACPI 2.0) FADT
* deprecate -hdachs
* improve -accel documentation
* hax fix
* qemu-char GSource bugfix

----------------------------------------------------------------
Abdallah Bouassida (1):
      target/i386: Add GDB XML register description support

Andreas Grapentin (1):
      use _Static_assert in QEMU_BUILD_BUG_ON

Brian Norris (2):
      get_maintainer: it's '--pattern-depth', not '-pattern-depth'
      get_maintainer: --r (list reviewer) is on by default

Dr. David Alan Gilbert (1):
      checkpatch: Disallow glib asserts in main code

Fam Zheng (1):
      dump: Acquire BQL around vm_start() in dump thread

Felipe Franciosi (2):
      libvhost-user: replace vasprintf() to fix build
      vhost-scsi: create a vhost-scsi-common abstraction

Joe Perches (2):
      get_maintainer: Teach get_maintainer.pl about the new "R:" tag
      get_maintainer: add subsystem to reviewer output

Jose Ricardo Ziviani (1):
      trace: add qemu mutex lock and unlock trace events

P J P (1):
      vmw_pvscsi: check message ring page count at initialisation

Paolo Bonzini (1):
      sgabios: update for "fix wrong video attrs for int 10h,ah==13h"

Paul E. McKenney (1):
      MAINTAINERS: Add "R:" tag for self-appointed reviewers

Phil Dennis-Jordan (2):
      hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support.
      hw/i386: Build-time assertion on pc/q35 reset register being identical.

Prasad J Pandit (1):
      scsi: avoid an off-by-one error in megasas_mmio_write

Thomas Huth (2):
      vl: deprecate the "-hdachs" option
      Fix the -accel parameter and the documentation for 'hax'

Yu Ning (1):
      hax: Fix memory mapping de-duplication logic

zhanghailiang (1):
      char: Fix removing wrong GSource that be found by fd_in_tag

 MAINTAINERS                           |   2 +
 chardev/char-fd.c                     |   8 +-
 chardev/char-io.c                     |  23 ++--
 chardev/char-io.h                     |   4 +-
 chardev/char-pty.c                    |   6 +-
 chardev/char-socket.c                 |   8 +-
 chardev/char-udp.c                    |   8 +-
 chardev/char.c                        |   2 +-
 configure                             |  20 ++++
 contrib/libvhost-user/libvhost-user.c |   2 +-
 dump.c                                |   7 ++
 gdb-xml/i386-32bit-core.xml           |  65 ++++++++++++
 gdb-xml/i386-64bit-core.xml           |  73 +++++++++++++
 hw/i386/acpi-build.c                  |  35 +++++-
 hw/pci-host/piix.c                    |   6 --
 hw/scsi/Makefile.objs                 |   2 +-
 hw/scsi/megasas.c                     |  10 +-
 hw/scsi/vhost-scsi-common.c           | 143 +++++++++++++++++++++++++
 hw/scsi/vhost-scsi.c                  | 194 ++++++++++------------------------
 hw/scsi/vmw_pvscsi.c                  |   2 +-
 include/hw/acpi/acpi-defs.h           |  77 +++++++-------
 include/hw/i386/pc.h                  |   6 ++
 include/hw/virtio/vhost-scsi-common.h |  48 +++++++++
 include/hw/virtio/vhost-scsi.h        |  11 +-
 include/hw/virtio/virtio-scsi.h       |   2 +
 include/qemu/compiler.h               |   4 +-
 include/sysemu/char.h                 |   2 +-
 include/sysemu/dump.h                 |   1 +
 pc-bios/sgabios.bin                   | Bin 4096 -> 4096 bytes
 qemu-options.hx                       |  22 ++--
 roms/sgabios                          |   2 +-
 scripts/checkpatch.pl                 |  21 ++++
 scripts/get_maintainer.pl             |  53 +++++++---
 target/i386/cpu.c                     |  21 +++-
 target/i386/hax-mem.c                 |  19 +++-
 tests/acpi-utils.h                    |  10 ++
 tests/bios-tables-test.c              |  23 +++-
 util/qemu-thread-posix.c              |  18 +++-
 util/qemu-thread-win32.c              |  11 +-
 util/trace-events                     |   4 +
 vl.c                                  |  25 ++---
 41 files changed, 705 insertions(+), 295 deletions(-)
 create mode 100644 gdb-xml/i386-32bit-core.xml
 create mode 100644 gdb-xml/i386-64bit-core.xml
 create mode 100644 hw/scsi/vhost-scsi-common.c
 create mode 100644 include/hw/virtio/vhost-scsi-common.h
-- 
2.12.2

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

* [Qemu-devel] [PULL 01/21] hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support.
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 02/21] hw/i386: Build-time assertion on pc/q35 reset register being identical Paolo Bonzini
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Phil Dennis-Jordan

From: Phil Dennis-Jordan <phil@philjordan.eu>

This updates the FADT generated for x86/64 machine types from Revision 1 to 3. (Based on ACPI standard 2.0 instead of 1.0) The intention is to expose the reset register information to guest operating systems which require it, specifically OS X/macOS. Revision 1 FADTs do not contain the fields relating to the reset register.

The new layout and contents remains backwards-compatible with operating systems which only support ACPI 1.0, as the existing fields are not modified by this change, as the 64-bit and 32-bit variants are allowed to co-exist according to the ACPI 2.0 standard. No regressions became apparent in tests with a range of Windows (XP-10) and Linux versions.

The BIOS tables test suite's FADT checksum test has also been updated to reflect the new FADT layout and content.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Message-Id: <1489558827-28971-2-git-send-email-phil@philjordan.eu>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/acpi-build.c        | 32 +++++++++++++++++--
 include/hw/acpi/acpi-defs.h | 77 +++++++++++++++++++++------------------------
 tests/acpi-utils.h          | 10 ++++++
 tests/bios-tables-test.c    | 23 +++++++++++---
 4 files changed, 93 insertions(+), 49 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 2073108577..7997f06823 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -272,7 +272,7 @@ build_facs(GArray *table_data, BIOSLinker *linker)
 }
 
 /* Load chipset information in FADT */
-static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)
+static void fadt_setup(AcpiFadtDescriptorRev3 *fadt, AcpiPmInfo *pm)
 {
     fadt->model = 1;
     fadt->reserved1 = 0;
@@ -304,6 +304,28 @@ static void fadt_setup(AcpiFadtDescriptorRev1 *fadt, AcpiPmInfo *pm)
         fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_FORCE_APIC_CLUSTER_MODEL);
     }
     fadt->century = RTC_CENTURY;
+
+    fadt->flags |= cpu_to_le32(1 << ACPI_FADT_F_RESET_REG_SUP);
+    fadt->reset_value = 0xf;
+    fadt->reset_register.space_id = AML_SYSTEM_IO;
+    fadt->reset_register.bit_width = 8;
+    fadt->reset_register.address = cpu_to_le64(ICH9_RST_CNT_IOPORT);
+
+    fadt->xpm1a_event_block.space_id = AML_SYSTEM_IO;
+    fadt->xpm1a_event_block.bit_width = fadt->pm1_evt_len * 8;
+    fadt->xpm1a_event_block.address = cpu_to_le64(pm->io_base);
+
+    fadt->xpm1a_control_block.space_id = AML_SYSTEM_IO;
+    fadt->xpm1a_control_block.bit_width = fadt->pm1_cnt_len * 8;
+    fadt->xpm1a_control_block.address = cpu_to_le64(pm->io_base + 0x4);
+
+    fadt->xpm_timer_block.space_id = AML_SYSTEM_IO;
+    fadt->xpm_timer_block.bit_width = fadt->pm_tmr_len * 8;
+    fadt->xpm_timer_block.address = cpu_to_le64(pm->io_base + 0x8);
+
+    fadt->xgpe0_block.space_id = AML_SYSTEM_IO;
+    fadt->xgpe0_block.bit_width = pm->gpe0_blk_len * 8;
+    fadt->xgpe0_block.address = cpu_to_le64(pm->gpe0_blk);
 }
 
 
@@ -313,9 +335,10 @@ build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm,
            unsigned facs_tbl_offset, unsigned dsdt_tbl_offset,
            const char *oem_id, const char *oem_table_id)
 {
-    AcpiFadtDescriptorRev1 *fadt = acpi_data_push(table_data, sizeof(*fadt));
+    AcpiFadtDescriptorRev3 *fadt = acpi_data_push(table_data, sizeof(*fadt));
     unsigned fw_ctrl_offset = (char *)&fadt->firmware_ctrl - table_data->data;
     unsigned dsdt_entry_offset = (char *)&fadt->dsdt - table_data->data;
+    unsigned xdsdt_entry_offset = (char *)&fadt->Xdsdt - table_data->data;
 
     /* FACS address to be filled by Guest linker */
     bios_linker_loader_add_pointer(linker,
@@ -327,9 +350,12 @@ build_fadt(GArray *table_data, BIOSLinker *linker, AcpiPmInfo *pm,
     bios_linker_loader_add_pointer(linker,
         ACPI_BUILD_TABLE_FILE, dsdt_entry_offset, sizeof(fadt->dsdt),
         ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);
+    bios_linker_loader_add_pointer(linker,
+        ACPI_BUILD_TABLE_FILE, xdsdt_entry_offset, sizeof(fadt->Xdsdt),
+        ACPI_BUILD_TABLE_FILE, dsdt_tbl_offset);
 
     build_header(linker, table_data,
-                 (void *)fadt, "FACP", sizeof(*fadt), 1, oem_id, oem_table_id);
+                 (void *)fadt, "FACP", sizeof(*fadt), 3, oem_id, oem_table_id);
 }
 
 void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
index 4cc3630e61..293ee4524b 100644
--- a/include/hw/acpi/acpi-defs.h
+++ b/include/hw/acpi/acpi-defs.h
@@ -131,17 +131,37 @@ typedef struct AcpiTableHeader AcpiTableHeader;
     uint8_t  duty_width;   /* Bit width of duty cycle field in p_cnt reg */ \
     uint8_t  day_alrm;     /* Index to day-of-month alarm in RTC CMOS RAM */ \
     uint8_t  mon_alrm;     /* Index to month-of-year alarm in RTC CMOS RAM */ \
-    uint8_t  century;      /* Index to century in RTC CMOS RAM */
-
-struct AcpiFadtDescriptorRev1
-{
-    ACPI_FADT_COMMON_DEF
-    uint8_t  reserved4;              /* Reserved */
-    uint8_t  reserved4a;             /* Reserved */
-    uint8_t  reserved4b;             /* Reserved */
-    uint32_t flags;
-} QEMU_PACKED;
-typedef struct AcpiFadtDescriptorRev1 AcpiFadtDescriptorRev1;
+    uint8_t  century;      /* Index to century in RTC CMOS RAM */ \
+    /* IA-PC Boot Architecture Flags (see below for individual flags) */ \
+    uint16_t boot_flags; \
+    uint8_t reserved;    /* Reserved, must be zero */ \
+    /* Miscellaneous flag bits (see below for individual flags) */ \
+    uint32_t flags; \
+    /* 64-bit address of the Reset register */ \
+    struct AcpiGenericAddress reset_register; \
+    /* Value to write to the reset_register port to reset the system */ \
+    uint8_t reset_value; \
+    /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */ \
+    uint16_t arm_boot_flags; \
+    uint8_t minor_revision;  /* FADT Minor Revision (ACPI 5.1) */ \
+    uint64_t Xfacs;          /* 64-bit physical address of FACS */ \
+    uint64_t Xdsdt;          /* 64-bit physical address of DSDT */ \
+    /* 64-bit Extended Power Mgt 1a Event Reg Blk address */ \
+    struct AcpiGenericAddress xpm1a_event_block; \
+    /* 64-bit Extended Power Mgt 1b Event Reg Blk address */ \
+    struct AcpiGenericAddress xpm1b_event_block; \
+    /* 64-bit Extended Power Mgt 1a Control Reg Blk address */ \
+    struct AcpiGenericAddress xpm1a_control_block; \
+    /* 64-bit Extended Power Mgt 1b Control Reg Blk address */ \
+    struct AcpiGenericAddress xpm1b_control_block; \
+    /* 64-bit Extended Power Mgt 2 Control Reg Blk address */ \
+    struct AcpiGenericAddress xpm2_control_block; \
+    /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */ \
+    struct AcpiGenericAddress xpm_timer_block; \
+    /* 64-bit Extended General Purpose Event 0 Reg Blk address */ \
+    struct AcpiGenericAddress xgpe0_block; \
+    /* 64-bit Extended General Purpose Event 1 Reg Blk address */ \
+    struct AcpiGenericAddress xgpe1_block; \
 
 struct AcpiGenericAddress {
     uint8_t space_id;        /* Address space where struct or register exists */
@@ -151,38 +171,13 @@ struct AcpiGenericAddress {
     uint64_t address;        /* 64-bit address of struct or register */
 } QEMU_PACKED;
 
+struct AcpiFadtDescriptorRev3 {
+    ACPI_FADT_COMMON_DEF
+} QEMU_PACKED;
+typedef struct AcpiFadtDescriptorRev3 AcpiFadtDescriptorRev3;
+
 struct AcpiFadtDescriptorRev5_1 {
     ACPI_FADT_COMMON_DEF
-    /* IA-PC Boot Architecture Flags (see below for individual flags) */
-    uint16_t boot_flags;
-    uint8_t reserved;    /* Reserved, must be zero */
-    /* Miscellaneous flag bits (see below for individual flags) */
-    uint32_t flags;
-    /* 64-bit address of the Reset register */
-    struct AcpiGenericAddress reset_register;
-    /* Value to write to the reset_register port to reset the system */
-    uint8_t reset_value;
-    /* ARM-Specific Boot Flags (see below for individual flags) (ACPI 5.1) */
-    uint16_t arm_boot_flags;
-    uint8_t minor_revision;  /* FADT Minor Revision (ACPI 5.1) */
-    uint64_t Xfacs;          /* 64-bit physical address of FACS */
-    uint64_t Xdsdt;          /* 64-bit physical address of DSDT */
-    /* 64-bit Extended Power Mgt 1a Event Reg Blk address */
-    struct AcpiGenericAddress xpm1a_event_block;
-    /* 64-bit Extended Power Mgt 1b Event Reg Blk address */
-    struct AcpiGenericAddress xpm1b_event_block;
-    /* 64-bit Extended Power Mgt 1a Control Reg Blk address */
-    struct AcpiGenericAddress xpm1a_control_block;
-    /* 64-bit Extended Power Mgt 1b Control Reg Blk address */
-    struct AcpiGenericAddress xpm1b_control_block;
-    /* 64-bit Extended Power Mgt 2 Control Reg Blk address */
-    struct AcpiGenericAddress xpm2_control_block;
-    /* 64-bit Extended Power Mgt Timer Ctrl Reg Blk address */
-    struct AcpiGenericAddress xpm_timer_block;
-    /* 64-bit Extended General Purpose Event 0 Reg Blk address */
-    struct AcpiGenericAddress xgpe0_block;
-    /* 64-bit Extended General Purpose Event 1 Reg Blk address */
-    struct AcpiGenericAddress xgpe1_block;
     /* 64-bit Sleep Control register (ACPI 5.0) */
     struct AcpiGenericAddress sleep_control;
     /* 64-bit Sleep Status register (ACPI 5.0) */
diff --git a/tests/acpi-utils.h b/tests/acpi-utils.h
index 348e4d7931..f8d87236c6 100644
--- a/tests/acpi-utils.h
+++ b/tests/acpi-utils.h
@@ -87,6 +87,16 @@ typedef struct {
     g_assert_cmpstr(ACPI_ASSERT_CMP_str, ==, expected); \
 } while (0)
 
+#define ACPI_READ_GENERIC_ADDRESS(field, addr)       \
+    do {                                             \
+        ACPI_READ_FIELD((field).space_id, addr);     \
+        ACPI_READ_FIELD((field).bit_width, addr);    \
+        ACPI_READ_FIELD((field).bit_offset, addr);   \
+        ACPI_READ_FIELD((field).access_width, addr); \
+        ACPI_READ_FIELD((field).address, addr);      \
+    } while (0);
+
+
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(void);
 void acpi_parse_rsdp_table(uint32_t addr, AcpiRsdpDescriptor *rsdp_table);
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 88dbf97853..9c96a67053 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -29,7 +29,7 @@ typedef struct {
     uint32_t rsdp_addr;
     AcpiRsdpDescriptor rsdp_table;
     AcpiRsdtDescriptorRev1 rsdt_table;
-    AcpiFadtDescriptorRev1 fadt_table;
+    AcpiFadtDescriptorRev3 fadt_table;
     AcpiFacsDescriptorRev1 facs_table;
     uint32_t *rsdt_tables_addr;
     int rsdt_tables_nr;
@@ -126,7 +126,7 @@ static void test_acpi_rsdt_table(test_data *data)
 
 static void test_acpi_fadt_table(test_data *data)
 {
-    AcpiFadtDescriptorRev1 *fadt_table = &data->fadt_table;
+    AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table;
     uint32_t addr;
 
     /* FADT table comes first */
@@ -168,10 +168,23 @@ static void test_acpi_fadt_table(test_data *data)
     ACPI_READ_FIELD(fadt_table->day_alrm, addr);
     ACPI_READ_FIELD(fadt_table->mon_alrm, addr);
     ACPI_READ_FIELD(fadt_table->century, addr);
-    ACPI_READ_FIELD(fadt_table->reserved4, addr);
-    ACPI_READ_FIELD(fadt_table->reserved4a, addr);
-    ACPI_READ_FIELD(fadt_table->reserved4b, addr);
+    ACPI_READ_FIELD(fadt_table->boot_flags, addr);
+    ACPI_READ_FIELD(fadt_table->reserved, addr);
     ACPI_READ_FIELD(fadt_table->flags, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr);
+    ACPI_READ_FIELD(fadt_table->reset_value, addr);
+    ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr);
+    ACPI_READ_FIELD(fadt_table->minor_revision, addr);
+    ACPI_READ_FIELD(fadt_table->Xfacs, addr);
+    ACPI_READ_FIELD(fadt_table->Xdsdt, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr);
+    ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr);
 
     ACPI_ASSERT_CMP(fadt_table->signature, "FACP");
     g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, fadt_table->length));
-- 
2.12.2

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

* [Qemu-devel] [PULL 02/21] hw/i386: Build-time assertion on pc/q35 reset register being identical.
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 01/21] hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 03/21] char: Fix removing wrong GSource that be found by fd_in_tag Paolo Bonzini
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Phil Dennis-Jordan

From: Phil Dennis-Jordan <phil@philjordan.eu>

This adds a clarifying comment and build time assert to the FADT reset register field initialisation: the reset register is the same on both machine types.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
Message-Id: <1489558827-28971-3-git-send-email-phil@philjordan.eu>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/acpi-build.c | 3 +++
 hw/pci-host/piix.c   | 6 ------
 include/hw/i386/pc.h | 6 ++++++
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 7997f06823..1d8c645ed3 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -310,6 +310,9 @@ static void fadt_setup(AcpiFadtDescriptorRev3 *fadt, AcpiPmInfo *pm)
     fadt->reset_register.space_id = AML_SYSTEM_IO;
     fadt->reset_register.bit_width = 8;
     fadt->reset_register.address = cpu_to_le64(ICH9_RST_CNT_IOPORT);
+    /* The above need not be conditional on machine type because the reset port
+     * happens to be the same on PIIX (pc) and ICH9 (q35). */
+    QEMU_BUILD_BUG_ON(ICH9_RST_CNT_IOPORT != RCR_IOPORT);
 
     fadt->xpm1a_event_block.space_id = AML_SYSTEM_IO;
     fadt->xpm1a_event_block.bit_width = fadt->pm1_evt_len * 8;
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index f9218aa952..bf4221d4bf 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -58,12 +58,6 @@ typedef struct I440FXState {
 #define XEN_PIIX_NUM_PIRQS      128ULL
 #define PIIX_PIRQC              0x60
 
-/*
- * Reset Control Register: PCI-accessible ISA-Compatible Register at address
- * 0xcf9, provided by the PCI/ISA bridge (PIIX3 PCI function 0, 8086:7000).
- */
-#define RCR_IOPORT 0xcf9
-
 typedef struct PIIX3State {
     PCIDevice dev;
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index f278b3ae89..416aaa56ea 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -303,6 +303,12 @@ typedef struct PCII440FXState PCII440FXState;
 
 #define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX"
 
+/*
+ * Reset Control Register: PCI-accessible ISA-Compatible Register at address
+ * 0xcf9, provided by the PCI/ISA bridge (PIIX3 PCI function 0, 8086:7000).
+ */
+#define RCR_IOPORT 0xcf9
+
 PCIBus *i440fx_init(const char *host_type, const char *pci_type,
                     PCII440FXState **pi440fx_state, int *piix_devfn,
                     ISABus **isa_bus, qemu_irq *pic,
-- 
2.12.2

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

* [Qemu-devel] [PULL 03/21] char: Fix removing wrong GSource that be found by fd_in_tag
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 01/21] hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 02/21] hw/i386: Build-time assertion on pc/q35 reset register being identical Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 04/21] target/i386: Add GDB XML register description support Paolo Bonzini
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: zhanghailiang

From: zhanghailiang <zhang.zhanghailiang@huawei.com>

We use fd_in_tag to find a GSource, fd_in_tag is return value of
g_source_attach(GSource *source, GMainContext *context), the return
value is unique only in the same context, so we may get the same
values with different 'context' parameters.

It is no problem to find the right fd_in_tag by using
 g_main_context_find_source_by_id(GMainContext *context, guint source_id)
while there is only one default main context.

But colo-compare tries to create/use its own context, and if we pass wrong
'context' parameter with right fd_in_tag, we will find a wrong GSource to handle.
We tried to fix the related codes in commit b43decb015a6efeb9e3cdbdb80f6547ad7248a4c,
but it didn't fix the bug completely, because we still have some codes didn't pass
*right* context parameter for remove_fd_in_watch().

Let's fix it by record the GSource directly instead of fd_in_tag.

Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1492564532-91680-1-git-send-email-zhang.zhanghailiang@huawei.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 chardev/char-fd.c     |  8 ++++----
 chardev/char-io.c     | 23 ++++++++---------------
 chardev/char-io.h     |  4 ++--
 chardev/char-pty.c    |  6 +++---
 chardev/char-socket.c |  8 ++++----
 chardev/char-udp.c    |  8 ++++----
 chardev/char.c        |  2 +-
 include/sysemu/char.h |  2 +-
 8 files changed, 27 insertions(+), 34 deletions(-)

diff --git a/chardev/char-fd.c b/chardev/char-fd.c
index 548dd4cdd9..0b182c552c 100644
--- a/chardev/char-fd.c
+++ b/chardev/char-fd.c
@@ -58,7 +58,7 @@ static gboolean fd_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
     ret = qio_channel_read(
         chan, (gchar *)buf, len, NULL);
     if (ret == 0) {
-        remove_fd_in_watch(chr, NULL);
+        remove_fd_in_watch(chr);
         qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
         return FALSE;
     }
@@ -89,9 +89,9 @@ static void fd_chr_update_read_handler(Chardev *chr,
 {
     FDChardev *s = FD_CHARDEV(chr);
 
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     if (s->ioc_in) {
-        chr->fd_in_tag = io_add_watch_poll(chr, s->ioc_in,
+        chr->gsource = io_add_watch_poll(chr, s->ioc_in,
                                            fd_chr_read_poll,
                                            fd_chr_read, chr,
                                            context);
@@ -103,7 +103,7 @@ static void char_fd_finalize(Object *obj)
     Chardev *chr = CHARDEV(obj);
     FDChardev *s = FD_CHARDEV(obj);
 
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     if (s->ioc_in) {
         object_unref(OBJECT(s->ioc_in));
     }
diff --git a/chardev/char-io.c b/chardev/char-io.c
index b4bb094ea3..b5708eef45 100644
--- a/chardev/char-io.c
+++ b/chardev/char-io.c
@@ -98,7 +98,7 @@ static GSourceFuncs io_watch_poll_funcs = {
     .finalize = io_watch_poll_finalize,
 };
 
-guint io_add_watch_poll(Chardev *chr,
+GSource *io_add_watch_poll(Chardev *chr,
                         QIOChannel *ioc,
                         IOCanReadHandler *fd_can_read,
                         QIOChannelFunc fd_read,
@@ -106,7 +106,6 @@ guint io_add_watch_poll(Chardev *chr,
                         GMainContext *context)
 {
     IOWatchPoll *iwp;
-    int tag;
     char *name;
 
     iwp = (IOWatchPoll *) g_source_new(&io_watch_poll_funcs,
@@ -122,21 +121,15 @@ guint io_add_watch_poll(Chardev *chr,
     g_source_set_name((GSource *)iwp, name);
     g_free(name);
 
-    tag = g_source_attach(&iwp->parent, context);
+    g_source_attach(&iwp->parent, context);
     g_source_unref(&iwp->parent);
-    return tag;
+    return (GSource *)iwp;
 }
 
-static void io_remove_watch_poll(guint tag, GMainContext *context)
+static void io_remove_watch_poll(GSource *source)
 {
-    GSource *source;
     IOWatchPoll *iwp;
 
-    g_return_if_fail(tag > 0);
-
-    source = g_main_context_find_source_by_id(context, tag);
-    g_return_if_fail(source != NULL);
-
     iwp = io_watch_poll_from_source(source);
     if (iwp->src) {
         g_source_destroy(iwp->src);
@@ -146,11 +139,11 @@ static void io_remove_watch_poll(guint tag, GMainContext *context)
     g_source_destroy(&iwp->parent);
 }
 
-void remove_fd_in_watch(Chardev *chr, GMainContext *context)
+void remove_fd_in_watch(Chardev *chr)
 {
-    if (chr->fd_in_tag) {
-        io_remove_watch_poll(chr->fd_in_tag, context);
-        chr->fd_in_tag = 0;
+    if (chr->gsource) {
+        io_remove_watch_poll(chr->gsource);
+        chr->gsource = NULL;
     }
 }
 
diff --git a/chardev/char-io.h b/chardev/char-io.h
index 842be56bda..55973a7671 100644
--- a/chardev/char-io.h
+++ b/chardev/char-io.h
@@ -29,14 +29,14 @@
 #include "sysemu/char.h"
 
 /* Can only be used for read */
-guint io_add_watch_poll(Chardev *chr,
+GSource *io_add_watch_poll(Chardev *chr,
                         QIOChannel *ioc,
                         IOCanReadHandler *fd_can_read,
                         QIOChannelFunc fd_read,
                         gpointer user_data,
                         GMainContext *context);
 
-void remove_fd_in_watch(Chardev *chr, GMainContext *context);
+void remove_fd_in_watch(Chardev *chr);
 
 int io_channel_send(QIOChannel *ioc, const void *buf, size_t len);
 
diff --git a/chardev/char-pty.c b/chardev/char-pty.c
index a6337be8aa..581ab34278 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -199,7 +199,7 @@ static void pty_chr_state(Chardev *chr, int connected)
             g_source_remove(s->open_tag);
             s->open_tag = 0;
         }
-        remove_fd_in_watch(chr, NULL);
+        remove_fd_in_watch(chr);
         s->connected = 0;
         /* (re-)connect poll interval for idle guests: once per second.
          * We check more frequently in case the guests sends data to
@@ -215,8 +215,8 @@ static void pty_chr_state(Chardev *chr, int connected)
             s->connected = 1;
             s->open_tag = g_idle_add(qemu_chr_be_generic_open_func, chr);
         }
-        if (!chr->fd_in_tag) {
-            chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
+        if (!chr->gsource) {
+            chr->gsource = io_add_watch_poll(chr, s->ioc,
                                                pty_chr_read_poll,
                                                pty_chr_read,
                                                chr, NULL);
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 36ab0d633a..d8de0518c5 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -327,7 +327,7 @@ static void tcp_chr_free_connection(Chardev *chr)
     }
 
     tcp_set_msgfds(chr, NULL, 0);
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     object_unref(OBJECT(s->sioc));
     s->sioc = NULL;
     object_unref(OBJECT(s->ioc));
@@ -484,7 +484,7 @@ static void tcp_chr_connect(void *opaque)
 
     s->connected = 1;
     if (s->ioc) {
-        chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
+        chr->gsource = io_add_watch_poll(chr, s->ioc,
                                            tcp_chr_read_poll,
                                            tcp_chr_read,
                                            chr, NULL);
@@ -501,9 +501,9 @@ static void tcp_chr_update_read_handler(Chardev *chr,
         return;
     }
 
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     if (s->ioc) {
-        chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
+        chr->gsource = io_add_watch_poll(chr, s->ioc,
                                            tcp_chr_read_poll,
                                            tcp_chr_read, chr,
                                            context);
diff --git a/chardev/char-udp.c b/chardev/char-udp.c
index 804bd22efa..12240e528a 100644
--- a/chardev/char-udp.c
+++ b/chardev/char-udp.c
@@ -81,7 +81,7 @@ static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
     ret = qio_channel_read(
         s->ioc, (char *)s->buf, sizeof(s->buf), NULL);
     if (ret <= 0) {
-        remove_fd_in_watch(chr, NULL);
+        remove_fd_in_watch(chr);
         return FALSE;
     }
     s->bufcnt = ret;
@@ -101,9 +101,9 @@ static void udp_chr_update_read_handler(Chardev *chr,
 {
     UdpChardev *s = UDP_CHARDEV(chr);
 
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     if (s->ioc) {
-        chr->fd_in_tag = io_add_watch_poll(chr, s->ioc,
+        chr->gsource = io_add_watch_poll(chr, s->ioc,
                                            udp_chr_read_poll,
                                            udp_chr_read, chr,
                                            context);
@@ -115,7 +115,7 @@ static void char_udp_finalize(Object *obj)
     Chardev *chr = CHARDEV(obj);
     UdpChardev *s = UDP_CHARDEV(obj);
 
-    remove_fd_in_watch(chr, NULL);
+    remove_fd_in_watch(chr);
     if (s->ioc) {
         object_unref(OBJECT(s->ioc));
     }
diff --git a/chardev/char.c b/chardev/char.c
index 3df116350b..54cd5f4081 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -560,7 +560,7 @@ void qemu_chr_fe_set_handlers(CharBackend *b,
     cc = CHARDEV_GET_CLASS(s);
     if (!opaque && !fd_can_read && !fd_read && !fd_event) {
         fe_open = 0;
-        remove_fd_in_watch(s, context);
+        remove_fd_in_watch(s);
     } else {
         fe_open = 1;
     }
diff --git a/include/sysemu/char.h b/include/sysemu/char.h
index 450881d42c..84f5c2312c 100644
--- a/include/sysemu/char.h
+++ b/include/sysemu/char.h
@@ -93,7 +93,7 @@ struct Chardev {
     char *filename;
     int logfd;
     int be_open;
-    guint fd_in_tag;
+    GSource *gsource;
     DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST);
     QTAILQ_ENTRY(Chardev) next;
 };
-- 
2.12.2

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

* [Qemu-devel] [PULL 04/21] target/i386: Add GDB XML register description support
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (2 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 03/21] char: Fix removing wrong GSource that be found by fd_in_tag Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 05/21] use _Static_assert in QEMU_BUILD_BUG_ON Paolo Bonzini
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Abdallah Bouassida

From: Abdallah Bouassida <abdallah.bouassida@lauterbach.com>

This patch implements XML target description support for X86 and X86-64
architectures in the GDB stub, as the way with ARM and PowerPC:
- gdb-xml/32bit-core.xml & gdb-xml/64bit-core.xml: Adding the XML target
  description files, these files are picked from GDB source code.
- configure: Define gdb_xml_files for X86 targets.
- target/i386/cpu.c: Define gdb_core_xml_file and gdb_arch_name to add
  XML awareness for this architecture, modify the gdb_num_core_regs to
  fit the registers number defined in each XML file.

Signed-off-by: Abdallah Bouassida <abdallah.bouassida@lauterbach.com>
Message-Id: <2b3c8119-1602-28c7-eab4-296593877103@lauterbach.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                   |  2 ++
 gdb-xml/i386-32bit-core.xml | 65 ++++++++++++++++++++++++++++++++++++++++
 gdb-xml/i386-64bit-core.xml | 73 +++++++++++++++++++++++++++++++++++++++++++++
 target/i386/cpu.c           | 21 ++++++++++---
 4 files changed, 157 insertions(+), 4 deletions(-)
 create mode 100644 gdb-xml/i386-32bit-core.xml
 create mode 100644 gdb-xml/i386-64bit-core.xml

diff --git a/configure b/configure
index 48a9370cc6..ff2c81f2c7 100755
--- a/configure
+++ b/configure
@@ -6023,9 +6023,11 @@ TARGET_ABI_DIR=""
 
 case "$target_name" in
   i386)
+    gdb_xml_files="i386-32bit-core.xml"
   ;;
   x86_64)
     TARGET_BASE_ARCH=i386
+    gdb_xml_files="i386-64bit-core.xml"
   ;;
   alpha)
     mttcg="yes"
diff --git a/gdb-xml/i386-32bit-core.xml b/gdb-xml/i386-32bit-core.xml
new file mode 100644
index 0000000000..7aeeeca3b2
--- /dev/null
+++ b/gdb-xml/i386-32bit-core.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.core">
+  <flags id="i386_eflags" size="4">
+    <field name="CF" start="0" end="0"/>
+    <field name="" start="1" end="1"/>
+    <field name="PF" start="2" end="2"/>
+    <field name="AF" start="4" end="4"/>
+    <field name="ZF" start="6" end="6"/>
+    <field name="SF" start="7" end="7"/>
+    <field name="TF" start="8" end="8"/>
+    <field name="IF" start="9" end="9"/>
+    <field name="DF" start="10" end="10"/>
+    <field name="OF" start="11" end="11"/>
+    <field name="NT" start="14" end="14"/>
+    <field name="RF" start="16" end="16"/>
+    <field name="VM" start="17" end="17"/>
+    <field name="AC" start="18" end="18"/>
+    <field name="VIF" start="19" end="19"/>
+    <field name="VIP" start="20" end="20"/>
+    <field name="ID" start="21" end="21"/>
+  </flags>
+
+  <reg name="eax" bitsize="32" type="int32"/>
+  <reg name="ecx" bitsize="32" type="int32"/>
+  <reg name="edx" bitsize="32" type="int32"/>
+  <reg name="ebx" bitsize="32" type="int32"/>
+  <reg name="esp" bitsize="32" type="data_ptr"/>
+  <reg name="ebp" bitsize="32" type="data_ptr"/>
+  <reg name="esi" bitsize="32" type="int32"/>
+  <reg name="edi" bitsize="32" type="int32"/>
+
+  <reg name="eip" bitsize="32" type="code_ptr"/>
+  <reg name="eflags" bitsize="32" type="i386_eflags"/>
+  <reg name="cs" bitsize="32" type="int32"/>
+  <reg name="ss" bitsize="32" type="int32"/>
+  <reg name="ds" bitsize="32" type="int32"/>
+  <reg name="es" bitsize="32" type="int32"/>
+  <reg name="fs" bitsize="32" type="int32"/>
+  <reg name="gs" bitsize="32" type="int32"/>
+
+  <reg name="st0" bitsize="80" type="i387_ext"/>
+  <reg name="st1" bitsize="80" type="i387_ext"/>
+  <reg name="st2" bitsize="80" type="i387_ext"/>
+  <reg name="st3" bitsize="80" type="i387_ext"/>
+  <reg name="st4" bitsize="80" type="i387_ext"/>
+  <reg name="st5" bitsize="80" type="i387_ext"/>
+  <reg name="st6" bitsize="80" type="i387_ext"/>
+  <reg name="st7" bitsize="80" type="i387_ext"/>
+
+  <reg name="fctrl" bitsize="32" type="int" group="float"/>
+  <reg name="fstat" bitsize="32" type="int" group="float"/>
+  <reg name="ftag" bitsize="32" type="int" group="float"/>
+  <reg name="fiseg" bitsize="32" type="int" group="float"/>
+  <reg name="fioff" bitsize="32" type="int" group="float"/>
+  <reg name="foseg" bitsize="32" type="int" group="float"/>
+  <reg name="fooff" bitsize="32" type="int" group="float"/>
+  <reg name="fop" bitsize="32" type="int" group="float"/>
+</feature>
diff --git a/gdb-xml/i386-64bit-core.xml b/gdb-xml/i386-64bit-core.xml
new file mode 100644
index 0000000000..5088d84ceb
--- /dev/null
+++ b/gdb-xml/i386-64bit-core.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2010-2015 Free Software Foundation, Inc.
+
+     Copying and distribution of this file, with or without modification,
+     are permitted in any medium without royalty provided the copyright
+     notice and this notice are preserved.  -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.core">
+  <flags id="i386_eflags" size="4">
+    <field name="CF" start="0" end="0"/>
+    <field name="" start="1" end="1"/>
+    <field name="PF" start="2" end="2"/>
+    <field name="AF" start="4" end="4"/>
+    <field name="ZF" start="6" end="6"/>
+    <field name="SF" start="7" end="7"/>
+    <field name="TF" start="8" end="8"/>
+    <field name="IF" start="9" end="9"/>
+    <field name="DF" start="10" end="10"/>
+    <field name="OF" start="11" end="11"/>
+    <field name="NT" start="14" end="14"/>
+    <field name="RF" start="16" end="16"/>
+    <field name="VM" start="17" end="17"/>
+    <field name="AC" start="18" end="18"/>
+    <field name="VIF" start="19" end="19"/>
+    <field name="VIP" start="20" end="20"/>
+    <field name="ID" start="21" end="21"/>
+  </flags>
+
+  <reg name="rax" bitsize="64" type="int64"/>
+  <reg name="rbx" bitsize="64" type="int64"/>
+  <reg name="rcx" bitsize="64" type="int64"/>
+  <reg name="rdx" bitsize="64" type="int64"/>
+  <reg name="rsi" bitsize="64" type="int64"/>
+  <reg name="rdi" bitsize="64" type="int64"/>
+  <reg name="rbp" bitsize="64" type="data_ptr"/>
+  <reg name="rsp" bitsize="64" type="data_ptr"/>
+  <reg name="r8" bitsize="64" type="int64"/>
+  <reg name="r9" bitsize="64" type="int64"/>
+  <reg name="r10" bitsize="64" type="int64"/>
+  <reg name="r11" bitsize="64" type="int64"/>
+  <reg name="r12" bitsize="64" type="int64"/>
+  <reg name="r13" bitsize="64" type="int64"/>
+  <reg name="r14" bitsize="64" type="int64"/>
+  <reg name="r15" bitsize="64" type="int64"/>
+
+  <reg name="rip" bitsize="64" type="code_ptr"/>
+  <reg name="eflags" bitsize="32" type="i386_eflags"/>
+  <reg name="cs" bitsize="32" type="int32"/>
+  <reg name="ss" bitsize="32" type="int32"/>
+  <reg name="ds" bitsize="32" type="int32"/>
+  <reg name="es" bitsize="32" type="int32"/>
+  <reg name="fs" bitsize="32" type="int32"/>
+  <reg name="gs" bitsize="32" type="int32"/>
+
+  <reg name="st0" bitsize="80" type="i387_ext"/>
+  <reg name="st1" bitsize="80" type="i387_ext"/>
+  <reg name="st2" bitsize="80" type="i387_ext"/>
+  <reg name="st3" bitsize="80" type="i387_ext"/>
+  <reg name="st4" bitsize="80" type="i387_ext"/>
+  <reg name="st5" bitsize="80" type="i387_ext"/>
+  <reg name="st6" bitsize="80" type="i387_ext"/>
+  <reg name="st7" bitsize="80" type="i387_ext"/>
+
+  <reg name="fctrl" bitsize="32" type="int" group="float"/>
+  <reg name="fstat" bitsize="32" type="int" group="float"/>
+  <reg name="ftag" bitsize="32" type="int" group="float"/>
+  <reg name="fiseg" bitsize="32" type="int" group="float"/>
+  <reg name="fioff" bitsize="32" type="int" group="float"/>
+  <reg name="foseg" bitsize="32" type="int" group="float"/>
+  <reg name="fooff" bitsize="32" type="int" group="float"/>
+  <reg name="fop" bitsize="32" type="int" group="float"/>
+</feature>
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 13c0985f11..7e87031fad 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -2577,6 +2577,15 @@ out:
     return ret;
 }
 
+static gchar *x86_gdb_arch_name(CPUState *cs)
+{
+#ifdef TARGET_X86_64
+    return g_strdup("i386:x86-64");
+#else
+    return g_strdup("i386");
+#endif
+}
+
 X86CPU *cpu_x86_init(const char *cpu_model)
 {
     return X86_CPU(cpu_generic_init(TYPE_X86_CPU, cpu_model));
@@ -4056,10 +4065,14 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
     cc->write_elf32_qemunote = x86_cpu_write_elf32_qemunote;
     cc->vmsd = &vmstate_x86_cpu;
 #endif
-    /* CPU_NB_REGS * 2 = general regs + xmm regs
-     * 25 = eip, eflags, 6 seg regs, st[0-7], fctrl,...,fop, mxcsr.
-     */
-    cc->gdb_num_core_regs = CPU_NB_REGS * 2 + 25;
+    cc->gdb_arch_name = x86_gdb_arch_name;
+#ifdef TARGET_X86_64
+    cc->gdb_core_xml_file = "i386-64bit-core.xml";
+    cc->gdb_num_core_regs = 40;
+#else
+    cc->gdb_core_xml_file = "i386-32bit-core.xml";
+    cc->gdb_num_core_regs = 32;
+#endif
 #ifndef CONFIG_USER_ONLY
     cc->debug_excp_handler = breakpoint_handler;
 #endif
-- 
2.12.2

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

* [Qemu-devel] [PULL 05/21] use _Static_assert in QEMU_BUILD_BUG_ON
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (3 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 04/21] target/i386: Add GDB XML register description support Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 06/21] vl: deprecate the "-hdachs" option Paolo Bonzini
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andreas Grapentin

From: Andreas Grapentin <andreas@grapentin.org>

QEMU_BUILD_BUG_ON should use C11's _Static_assert, if the compiler supports it,
to provide more readable messages on failure.

We check for _Static_assert in configure, and set CONFIG_STATIC_ASSERT
accordingly. QEMU_BUILD_BUG_ON invokes _Static_assert if CONFIG_STATIC_ASSERT
is defined, and reverts to the old way otherwise.

That way, systems without C11 conforming compiler will still have the old
messages, as verified by intentionally breaking the configure check.

the following example output was generated by inverting the condition in
QEMU_BUILD_BUG_ON:

without _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>                  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function ‘qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:89:12: error: negative width in bit-field ‘<anonymous>’
>      struct { \
>             ^
> /qemu/include/qemu/compiler.h:96:38: note: in expansion of macro  QEMU_BUILD_BUG_ON_STRUCT’
>  #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
>                                       ^~~~~~~~~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro ‘QEMU_BUILD_BUG_ON’
>      QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>      ^~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro ‘atomic_load_acquire’
>      atomic_load_acquire(ptr)
>      ^~~~~~~~~~~~~~~~~~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’
>      bool finished = atomic_mb_read(&gei->finished);
>                      ^~~~~~~~~~~~~~

with _Static_assert:

> In file included from /qemu/include/qemu/osdep.h:36:0,
>                  from /qemu/qga/commands.c:13:
> /qemu/qga/commands.c: In function ‘qmp_guest_exec_status’:
> /qemu/include/qemu/compiler.h:94:30: error: static assertion failed: "not expecting: sizeof(*&gei->finished) > sizeof(void *)"
>  #define QEMU_BUILD_BUG_ON(x) _Static_assert((x), #x)
>                               ^
> /qemu/include/qemu/atomic.h:146:5: note: in expansion of macro ‘QEMU_BUILD_BUG_ON’
>      QEMU_BUILD_BUG_ON(sizeof(*ptr) > sizeof(void *));   \
>      ^~~~~~~~~~~~~~~~~
> /qemu/include/qemu/atomic.h:417:5: note: in expansion of macro ‘atomic_load_acquire’
>      atomic_load_acquire(ptr)
>      ^~~~~~~~~~~~~~~~~~~
> /qemu/qga/commands.c:160:21: note: in expansion of macro ‘atomic_mb_read’
>      bool finished = atomic_mb_read(&gei->finished);
>                      ^~~~~~~~~~~~~~

Signed-off-by: Andreas Grapentin <andreas@grapentin.org>
Message-Id: <20170314165953.18506-1-andreas@grapentin.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure               | 18 ++++++++++++++++++
 include/qemu/compiler.h |  4 +++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index ff2c81f2c7..7c020c076b 100755
--- a/configure
+++ b/configure
@@ -4853,6 +4853,20 @@ EOF
 fi
 
 ##########################################
+# check for _Static_assert()
+
+have_static_assert=no
+cat > $TMPC << EOF
+_Static_assert(1, "success");
+int main(void) {
+    return 0;
+}
+EOF
+if compile_prog "" "" ; then
+    have_static_assert=yes
+fi
+
+##########################################
 # End of CC checks
 # After here, no more $cc or $ld runs
 
@@ -5848,6 +5862,10 @@ if test "$have_sysmacros" = "yes" ; then
   echo "CONFIG_SYSMACROS=y" >> $config_host_mak
 fi
 
+if test "$have_static_assert" = "yes" ; then
+  echo "CONFIG_STATIC_ASSERT=y" >> $config_host_mak
+fi
+
 # Hold two types of flag:
 #   CONFIG_THREAD_SETNAME_BYTHREAD  - we've got a way of setting the name on
 #                                     a thread we have a handle to
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 18e610083a..340e5fdc09 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -82,7 +82,9 @@
         int:(x) ? -1 : 1; \
     }
 
-#ifdef __COUNTER__
+#if defined(CONFIG_STATIC_ASSERT)
+#define QEMU_BUILD_BUG_ON(x) _Static_assert(!(x), "not expecting: " #x)
+#elif defined(__COUNTER__)
 #define QEMU_BUILD_BUG_ON(x) typedef QEMU_BUILD_BUG_ON_STRUCT(x) \
     glue(qemu_build_bug_on__, __COUNTER__) __attribute__((unused))
 #else
-- 
2.12.2

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

* [Qemu-devel] [PULL 06/21] vl: deprecate the "-hdachs" option
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (4 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 05/21] use _Static_assert in QEMU_BUILD_BUG_ON Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 07/21] scsi: avoid an off-by-one error in megasas_mmio_write Paolo Bonzini
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

If the user needs to specify the disk geometry, the corresponding
parameters of the "-device ide-hd" option should be used instead.
"-hdachs" is considered as deprecated and might be removed soon.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1493270454-1448-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-options.hx | 4 ++--
 vl.c            | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index 787b9c38da..f68829f3b0 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -803,8 +803,8 @@ STEXI
 Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
 @var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
 translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
-all those parameters. This option is useful for old MS-DOS disk
-images.
+all those parameters. This option is deprecated, please use
+@code{-device ide-hd,cyls=c,heads=h,secs=s,...} instead.
 ETEXI
 
 DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
diff --git a/vl.c b/vl.c
index f46e070e0d..42d4bce439 100644
--- a/vl.c
+++ b/vl.c
@@ -3231,6 +3231,8 @@ int main(int argc, char **argv, char **envp)
                         }
                     }
                 }
+                error_report("'-hdachs' is deprecated, please use '-device"
+                             " ide-hd,cyls=c,heads=h,secs=s,...' instead");
                 break;
             case QEMU_OPTION_numa:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
-- 
2.12.2

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

* [Qemu-devel] [PULL 07/21] scsi: avoid an off-by-one error in megasas_mmio_write
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (5 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 06/21] vl: deprecate the "-hdachs" option Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 08/21] sgabios: update for "fix wrong video attrs for int 10h, ah==13h" Paolo Bonzini
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

While reading magic sequence(MFI_SEQ) in megasas_mmio_write,
an off-by-one error could occur as 's->adp_reset' index is not
reset after reading the last sequence.

Reported-by: YY Z <bigbird475958471@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Message-Id: <20170424120634.12268-1-ppandit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/megasas.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 84b8caf901..804122ab05 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -2138,15 +2138,15 @@ static void megasas_mmio_write(void *opaque, hwaddr addr,
     case MFI_SEQ:
         trace_megasas_mmio_writel("MFI_SEQ", val);
         /* Magic sequence to start ADP reset */
-        if (adp_reset_seq[s->adp_reset] == val) {
-            s->adp_reset++;
+        if (adp_reset_seq[s->adp_reset++] == val) {
+            if (s->adp_reset == 6) {
+                s->adp_reset = 0;
+                s->diag = MFI_DIAG_WRITE_ENABLE;
+            }
         } else {
             s->adp_reset = 0;
             s->diag = 0;
         }
-        if (s->adp_reset == 6) {
-            s->diag = MFI_DIAG_WRITE_ENABLE;
-        }
         break;
     case MFI_DIAG:
         trace_megasas_mmio_writel("MFI_DIAG", val);
-- 
2.12.2

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

* [Qemu-devel] [PULL 08/21] sgabios: update for "fix wrong video attrs for int 10h, ah==13h"
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (6 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 07/21] scsi: avoid an off-by-one error in megasas_mmio_write Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 09/21] vmw_pvscsi: check message ring page count at initialisation Paolo Bonzini
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel

Update the submodule and rebuild the binary.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 pc-bios/sgabios.bin | Bin 4096 -> 4096 bytes
 roms/sgabios        |   2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/pc-bios/sgabios.bin b/pc-bios/sgabios.bin
index c3da4c3d0a34e4eca9b0cda38d0538b332f7b09e..6308f2e2d7064b52ff3c2e207b71018710866c05 100644
GIT binary patch
delta 1136
zcmX|<Z%i9?7{`BiM|*9D?J|@#khM3(%h;Nu1xDGN4PzLU_@`@ulmZ6aEJEVOX3wZ`
zwoNB#sk)Kh3uCeuu=#@UrZ*QCkysfet0Tq@W5h+w&}_-mFgo2LS+D>6-E@2P{XGA^
z&+ndGkPC8}&S_1$SC{S@*Ys(ujdk_*I-7m`Eo1HBqeq6`f5Yz|s^tcUj&k*OZeZj%
zS8ui1Eu6JkXlN346YA_ZF#b*JmsBrRYod8y>^YU-J6A=s=7D6tNo|-IZZVgd^oWgK
z7JM<GiWXuH6aI+)a1%${O8I+V2r(0f^~}?Dj@Fj^O}sDkto!->NVM>=J~bZ+A<A$u
zxwHyrRiPB3sT3c5;y@^eD3P}PM!YyY%xv58VD`|X*>32?pEEn3<mgbU$jl(>Zakc#
z`8_JJDs%_Y!Y&6#FWnIsGJT6l?>ExndCEGM3D46K&IqweBRxx@$gi2m{nr1&@H`_`
zkUAwX4->RRWqQ1xq|%NJs!D^AzC9Hb*CX>Ly?OR8gd0^Y)J-g^UaB_InQqeQCWWb>
zUtJTJJxwj|<K8Zt9l<Lq3w0Z7)y>s$bet8&D&wfQDC}*L9z;ZnKf*EGtG+^Q#yoqt
z%$rU3;!oM_lo3npZj(0abb-0xXQwDX1H&b+CtY*j>2{gO+2Jl`G$#yx1S5rTmU@SI
zacvD8_>`u0yIZLnE~aYOYpZ3>XfnFh+~Y}_+$1~Zcpbs-cv;gQXqL@a$tOJqpA@8e
z=+8^-(38Kw!uf)=Wcw-ISL$-XXQk*b-hIe#aKc~#b`>Ny*z?}klFrc^5G{<}P!?&g
zh>r(LtZ0BX#b~Qyv?af0aYYxQuH-#vUEjElmWr2zy?Sy4l`uxc&q@pjd+?0*Df{1f
z_$n`Tz@;297DA44gyuvhyg(=WK`y#FqqkyR`o1?`(Ve_0GU>WfFi#Vm#1%R|&{PcO
zbtGyaswY}a)Ic;rw1Q}3(c^t&35SXU>FIyIUPNbP^79TOR&VBglRJ>_+%h6yA+VxA
z3jv)1P6B@@;2~f@d`i6oy~pw&>vt+_L2Vx>fuIB}2(*M-6?US4l6NWWLCXqz5v*px
zB8$1ic?4o^xP@Gf{mzNt1)SG)1SItTGyQrY;)tU)R!FIhG|<*L(loOf<?l`F&2T0w
zW}q#XAlv?w;h9|GWdzq{sLv&iAh;$&ZSJ8>cj9{l37KpWCgSL9JGxAsg<wUN-UY}C
z6B3Fn6n}{DCsBkyh*Yp3!#e(Xlg%QbF}@uM5k8J!+Xj5Qk+_PWT^1%edUO?z$r1-A
ZvXNC7l;JeCmA{Ie<@yW3@&H3M{0n1!(*FPe

delta 1123
zcmX|=ZA@EL7{{M`FXgr!wu?i2S=L?^ZwkZ1EeLMN2-|dK1WgBQDOD5(G+WKYK<{)P
zT-&gamM&T5{ot2rI`IRUiPn%zmtu$1(144|qE161M3?w<jABH|di&<N)A{NDd*07^
za*ki{3;M&C^eK-qHE>?vqqo~@rTSXC{rriC8cy}S<{|RP;PA+)5i&eDaIDWu`iD+b
z30=oz;l-hof>1Bm>znH9n;PuG;jaBcokR;i-uLP4UZ#q$qC5PYj<_ePS>D>0=(UuZ
zBc4`kvC#y4XpXqUq?#q+7NW@P=`9j#FXlErBw>rB6xb)8mRLj4+bFsNdpe)r3v!JZ
z?kN?60btCR6N@Vt(FKygGD$J?!2UoM7@4&%(O#0`;&$ABx3>TP+HQ0yA+Gu{i47zR
z+!bK{{A4uAio134BY|~b$<7vuU0f#|t^R>a?X|I^vy3#89-U>QN}7Z#Y;25y;7{q`
zoqhkBqqAIe8;vtj?w*5<GU=CG&V-h(6iX`1Hum<UUtSB&T1?g$FiNGamHA5<)U|K7
zvFUD_*+~PFes5`|FBV~LGz%joF~4$6SHs*=GP+&cV=&B<@roD}7D!X$^j(We;Ts%M
z+DqpdL8;&eN{(bwPUSTJC}UG1e1k=oade<H@8u^MFNdC@%b6;_<LK<L(6!?q$_D?o
zc^L4G{Ah+b$sJr>#b(8)ud-@k^W|hE|J_Q7Ba{d|Xmutmozywrauje`nb-IFnpEqz
z^g{RHxqP$^kLIFn*pr*$aVjqr?blPU7LRn`yT#Ctu4eF>9e6yCPv)bYxI5>1CE*xb
z#&CXYS({^+m&^S{UN++at<l3;qw?HpO-E<}Ym2T!(%R<Fuvqw#G@0lMbYz^0mydD+
zKBIhOc-*j&!_RWjE=(vl43@1g8_(R7xm0b@pJS;`C_1C)+g0%AjMQqNYNEP>s+nq>
z>Ncv41*eMyTFL-sWDffaeW?q7f4%@0RQf_az?-b1`=Slp6Tbn48VaaED+Qwl4hm};
zI4PJxOqSXp#EWN5)f(5pvu8DfXhth+8Yu76*a7D>e}~3S_+4Wc;IA1Zs+^5~0r+Ot
z(@Gb_Uv&VsDQRPuZyNqPrq@J*EiqW-2_42FE6vcPD_bGAami%G_cL-D4`k!5fHzg#
zla0RsxTNA!+4$>#*Hzq^z1OBY{ypG~N~e%W3_fUsIeIL>U)1PZcq>C9(-8csa4jgF
zfuMK@bU3Htx-z%LUN;TnVjGa47z4C!;?>Rg5@5SZE=ug!3XZ5z0ezX^3LaPS9hH9e
R_r6x_We2DHWj>Cv{sTIk(ntUR

diff --git a/roms/sgabios b/roms/sgabios
index 23d474943d..cbaee52287 160000
--- a/roms/sgabios
+++ b/roms/sgabios
@@ -1 +1 @@
-Subproject commit 23d474943dcd55d0550a3d20b3d30e9040a4f15b
+Subproject commit cbaee52287e5f32373181cff50a00b6c4ac9015a
-- 
2.12.2

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

* [Qemu-devel] [PULL 09/21] vmw_pvscsi: check message ring page count at initialisation
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (7 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 08/21] sgabios: update for "fix wrong video attrs for int 10h, ah==13h" Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 10/21] trace: add qemu mutex lock and unlock trace events Paolo Bonzini
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: P J P

From: P J P <ppandit@redhat.com>

A guest could set the message ring page count to zero, resulting in
infinite loop. Add check to avoid it.

Reported-by: YY Z <bigbird475958471@gmail.com>
Signed-off-by: P J P <ppandit@redhat.com>
Message-Id: <20170425130623.3649-1-ppandit@redhat.com>
Reviewed-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/vmw_pvscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index 75575461e2..4a106da856 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -202,7 +202,7 @@ pvscsi_ring_init_msg(PVSCSIRingInfo *m, PVSCSICmdDescSetupMsgRing *ri)
     uint32_t len_log2;
     uint32_t ring_size;
 
-    if (ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
+    if (!ri->numPages || ri->numPages > PVSCSI_SETUP_MSG_RING_MAX_NUM_PAGES) {
         return -1;
     }
     ring_size = ri->numPages * PVSCSI_MAX_NUM_MSG_ENTRIES_PER_PAGE;
-- 
2.12.2

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

* [Qemu-devel] [PULL 10/21] trace: add qemu mutex lock and unlock trace events
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (8 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 09/21] vmw_pvscsi: check message ring page count at initialisation Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 11/21] checkpatch: Disallow glib asserts in main code Paolo Bonzini
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jose Ricardo Ziviani

From: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>

These trace events were very useful to help me to understand and find a
reordering issue in vfio, for example:

qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc0, 0x2020c, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc4, 0xa0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8

that also helped me to see the desired result after the fix:

qemu_mutex_lock locked mutex 0x10905ad8
  vfio_region_write  (0001:03:00.0:region1+0xc0, 0x2000c, 4)
  vfio_region_write  (0001:03:00.0:region1+0xc4, 0xb0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8

So it could be a good idea to have these traces implemented. It's worth
mentioning that they should be surgically enabled during the debugging,
otherwise it can flood the trace logs with lock/unlock messages.

How to use it:
trace-event qemu_mutex_lock on|off
trace-event qemu_mutex_unlock on|off
or
trace-event qemu_mutex* on|off

Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Message-Id: <1493054398-26013-1-git-send-email-joserz@linux.vnet.ibm.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
[Also handle trylock, cond_wait and win32; trace "unlocked" while still
 in the critical section, so that "unlocked" always comes before the
 next "locked" tracepoint. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 util/qemu-thread-posix.c | 18 +++++++++++++++++-
 util/qemu-thread-win32.c | 11 ++++++++++-
 util/trace-events        |  4 ++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 73e3a0edf5..eacd99e497 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -14,6 +14,7 @@
 #include "qemu/thread.h"
 #include "qemu/atomic.h"
 #include "qemu/notify.h"
+#include "trace.h"
 
 static bool name_threads;
 
@@ -60,17 +61,30 @@ void qemu_mutex_lock(QemuMutex *mutex)
     err = pthread_mutex_lock(&mutex->lock);
     if (err)
         error_exit(err, __func__);
+
+    trace_qemu_mutex_locked(mutex);
 }
 
 int qemu_mutex_trylock(QemuMutex *mutex)
 {
-    return pthread_mutex_trylock(&mutex->lock);
+    int err;
+
+    err = pthread_mutex_trylock(&mutex->lock);
+    if (err == 0) {
+        trace_qemu_mutex_locked(mutex);
+        return 0;
+    }
+    if (err != EBUSY) {
+        error_exit(err, __func__);
+    }
+    return -EBUSY;
 }
 
 void qemu_mutex_unlock(QemuMutex *mutex)
 {
     int err;
 
+    trace_qemu_mutex_unlocked(mutex);
     err = pthread_mutex_unlock(&mutex->lock);
     if (err)
         error_exit(err, __func__);
@@ -130,7 +144,9 @@ void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex)
 {
     int err;
 
+    trace_qemu_mutex_unlocked(mutex);
     err = pthread_cond_wait(&cond->cond, &mutex->lock);
+    trace_qemu_mutex_locked(mutex);
     if (err)
         error_exit(err, __func__);
 }
diff --git a/util/qemu-thread-win32.c b/util/qemu-thread-win32.c
index 59befd5202..653f29f442 100644
--- a/util/qemu-thread-win32.c
+++ b/util/qemu-thread-win32.c
@@ -19,6 +19,7 @@
 #include "qemu-common.h"
 #include "qemu/thread.h"
 #include "qemu/notify.h"
+#include "trace.h"
 #include <process.h>
 
 static bool name_threads;
@@ -55,6 +56,7 @@ void qemu_mutex_destroy(QemuMutex *mutex)
 void qemu_mutex_lock(QemuMutex *mutex)
 {
     AcquireSRWLockExclusive(&mutex->lock);
+    trace_qemu_mutex_locked(mutex);
 }
 
 int qemu_mutex_trylock(QemuMutex *mutex)
@@ -62,11 +64,16 @@ int qemu_mutex_trylock(QemuMutex *mutex)
     int owned;
 
     owned = TryAcquireSRWLockExclusive(&mutex->lock);
-    return !owned;
+    if (owned) {
+        trace_qemu_mutex_locked(mutex);
+        return 0;
+    }
+    return -EBUSY;
 }
 
 void qemu_mutex_unlock(QemuMutex *mutex)
 {
+    trace_qemu_mutex_unlocked(mutex);
     ReleaseSRWLockExclusive(&mutex->lock);
 }
 
@@ -118,7 +125,9 @@ void qemu_cond_broadcast(QemuCond *cond)
 
 void qemu_cond_wait(QemuCond *cond, QemuMutex *mutex)
 {
+    trace_qemu_mutex_unlocked(mutex);
     SleepConditionVariableSRW(&cond->var, &mutex->lock, INFINITE, 0);
+    trace_qemu_mutex_locked(mutex);
 }
 
 void qemu_sem_init(QemuSemaphore *sem, int init)
diff --git a/util/trace-events b/util/trace-events
index b44ef4f895..fa540c620b 100644
--- a/util/trace-events
+++ b/util/trace-events
@@ -55,3 +55,7 @@ lockcnt_futex_wait_prepare(const void *lockcnt, int expected, int new) "lockcnt
 lockcnt_futex_wait(const void *lockcnt, int val) "lockcnt %p waiting on %d"
 lockcnt_futex_wait_resume(const void *lockcnt, int new) "lockcnt %p after wait: %d"
 lockcnt_futex_wake(const void *lockcnt) "lockcnt %p waking up one waiter"
+
+# util/qemu-thread-posix.c
+qemu_mutex_locked(void *lock) "locked mutex %p"
+qemu_mutex_unlocked(void *lock) "unlocked mutex %p"
-- 
2.12.2

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

* [Qemu-devel] [PULL 11/21] checkpatch: Disallow glib asserts in main code
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (9 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 10/21] trace: add qemu mutex lock and unlock trace events Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 12/21] hax: Fix memory mapping de-duplication logic Paolo Bonzini
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dr. David Alan Gilbert

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Glib commit a6a875068779 (from 2013) made many of the glib assert
macros non-fatal if a flag is set.
This causes two problems:
  a) Compilers moan that your code is unsafe even though you've
     put an assert in before the point of use.
  b) Someone evil could, in a library, call
     g_test_set_nonfatal_assertions() and cause our assertions in
     important places not to fail and potentially allow memory overruns.

Ban most of the glib assertion functions (basically everything except
g_assert and g_assert_not_reached) except in tests/

This makes checkpatch gives an error such as:

  ERROR: Use g_assert or g_assert_not_reached
  #77: FILE: vl.c:4725:
  +    g_assert_cmpstr("Chocolate", >, "Cheese");

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20170427165526.19836-1-dgilbert@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/checkpatch.pl | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f084542934..73cee81b79 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2571,6 +2571,27 @@ sub process {
 		if ($line =~ /\bbzero\(/) {
 			ERROR("use memset() instead of bzero()\n" . $herecurr);
 		}
+		my $non_exit_glib_asserts = qr{g_assert_cmpstr|
+						g_assert_cmpint|
+						g_assert_cmpuint|
+						g_assert_cmphex|
+						g_assert_cmpfloat|
+						g_assert_true|
+						g_assert_false|
+						g_assert_nonnull|
+						g_assert_null|
+						g_assert_no_error|
+						g_assert_error|
+						g_test_assert_expected_messages|
+						g_test_trap_assert_passed|
+						g_test_trap_assert_stdout|
+						g_test_trap_assert_stdout_unmatched|
+						g_test_trap_assert_stderr|
+						g_test_trap_assert_stderr_unmatched}x;
+		if ($realfile !~ /^tests\// &&
+			$line =~ /\b(?:$non_exit_glib_asserts)\(/) {
+			ERROR("Use g_assert or g_assert_not_reached\n". $herecurr);
+		}
 	}
 
 	# If we have no input at all, then there is nothing to report on
-- 
2.12.2

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

* [Qemu-devel] [PULL 12/21] hax: Fix memory mapping de-duplication logic
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (10 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 11/21] checkpatch: Disallow glib asserts in main code Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 13/21] dump: Acquire BQL around vm_start() in dump thread Paolo Bonzini
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Yu Ning

From: Yu Ning <yu.ning@linux.intel.com>

hax_update_mapping() avoids unnecessary and potentially expensive
calls to HAX_VM_IOCTL_SET_RAM by computing the net result (i.e.
effective mapping changes) of each MemoryRegion transaction, with
the help of a linked list of HAXMapping objects.

However, when processing a new mapping that overlaps with an
existing mapping in the list, it fails to handle the case where the
start address of the new mapping is above that of the existing
mapping in the guest physical address space. This happens when QEMU
is launched with "-machine q35 -enable-hax", which involves the
following MemoryRegion transaction for digging the VGA hole:

 region_del: 0x00000000->0x08000000 VA 05fa0000 ('pc.ram')
 region_add: 0x00000000->0x000a0000 VA 05fa0000 ('pc.ram')
 region_add: 0x000a0000->0x000c0000 VA 00000000 ('vga-lowmem')
 region_add: 0x000c0000->0x08000000 VA 06060000 ('pc.ram')

where the third MemoryRegion is MMIO and is ignored. The current
de-duplication logic handles the last MemoryRegion incorrectly and
produces the following result:

 hax_mapping_dump_list updates:
         + 0x000c0000->0x08000000 VA 0x06060000
         - 0x07fe0000->0x08000000 VA 0x0df80000

which is why VGA emulation does not work for Q35.

With this patch, one can see VGA output as Q35 boots up. Note that
Q35 support also requires a change to HAXM kernel module, which is
not available in the current HAXM release (6.1.2).

+ Add a warning if the input MemoryRegion is a ROM device, which is
  not supported by HAXM kernel module at this time.

Signed-off-by: Yu Ning <yu.ning@linux.intel.com>
Message-Id: <20170428072723.7036-1-yu.ning@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 target/i386/hax-mem.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/target/i386/hax-mem.c b/target/i386/hax-mem.c
index 2884040021..af090343f3 100644
--- a/target/i386/hax-mem.c
+++ b/target/i386/hax-mem.c
@@ -106,10 +106,10 @@ static void hax_update_mapping(uint64_t start_pa, uint32_t size,
                                uint64_t host_va, uint8_t flags)
 {
     uint64_t end_pa = start_pa + size;
-    uint32_t chunk_sz;
     HAXMapping *entry, *next;
 
     QTAILQ_FOREACH_SAFE(entry, &mappings, entry, next) {
+        uint32_t chunk_sz;
         if (start_pa >= entry->start_pa + entry->size) {
             continue;
         }
@@ -121,7 +121,16 @@ static void hax_update_mapping(uint64_t start_pa, uint32_t size,
             start_pa += chunk_sz;
             host_va += chunk_sz;
             size -= chunk_sz;
+        } else if (start_pa > entry->start_pa) {
+            /* split the existing chunk at start_pa */
+            chunk_sz = start_pa - entry->start_pa;
+            hax_insert_mapping_before(entry, entry->start_pa, chunk_sz,
+                                      entry->host_va, entry->flags);
+            entry->start_pa += chunk_sz;
+            entry->host_va += chunk_sz;
+            entry->size -= chunk_sz;
         }
+        /* now start_pa == entry->start_pa */
         chunk_sz = MIN(size, entry->size);
         if (chunk_sz) {
             bool nop = hax_mapping_is_opposite(entry, host_va, flags);
@@ -165,8 +174,14 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags)
     unsigned int delta;
     uint64_t host_va;
 
-    /* We only care about RAM pages */
+    /* We only care about RAM and ROM regions */
     if (!memory_region_is_ram(mr)) {
+        if (memory_region_is_romd(mr)) {
+            /* HAXM kernel module does not support ROMD yet  */
+            fprintf(stderr, "%s: Warning: Ignoring ROMD region 0x%016" PRIx64
+                    "->0x%016" PRIx64 "\n", __func__, start_pa,
+                    start_pa + size);
+        }
         return;
     }
 
-- 
2.12.2

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

* [Qemu-devel] [PULL 13/21] dump: Acquire BQL around vm_start() in dump thread
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (11 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 12/21] hax: Fix memory mapping de-duplication logic Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 14/21] Fix the -accel parameter and the documentation for 'hax' Paolo Bonzini
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Fam Zheng

From: Fam Zheng <famz@redhat.com>

This fixes an assertion failure in the following backtrace:

    __GI___assert_fail
    memory_region_transaction_commit
    memory_region_add_eventfd
    virtio_pci_ioeventfd_assign
    virtio_bus_set_host_notifier
    virtio_blk_data_plane_start
    virtio_bus_start_ioeventfd
    virtio_vmstate_change
    vm_state_notify
    vm_prepare_start
    vm_start
    dump_cleanup
    dump_process
    dump_thread
    start_thread
    clone

vm_start need BQL, acquire it if doing cleaning up from main thread.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170503072819.14462-1-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 dump.c                | 7 +++++++
 include/sysemu/dump.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/dump.c b/dump.c
index f7b80d856b..d9090a24cc 100644
--- a/dump.c
+++ b/dump.c
@@ -77,7 +77,13 @@ static int dump_cleanup(DumpState *s)
     memory_mapping_list_free(&s->list);
     close(s->fd);
     if (s->resume) {
+        if (s->detached) {
+            qemu_mutex_lock_iothread();
+        }
         vm_start();
+        if (s->detached) {
+            qemu_mutex_unlock_iothread();
+        }
     }
 
     return 0;
@@ -1804,6 +1810,7 @@ void qmp_dump_guest_memory(bool paging, const char *file,
 
     if (detach_p) {
         /* detached dump */
+        s->detached = true;
         qemu_thread_create(&s->dump_thread, "dump_thread", dump_thread,
                            s, QEMU_THREAD_DETACHED);
     } else {
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
index ef931be469..2672a15f8b 100644
--- a/include/sysemu/dump.h
+++ b/include/sysemu/dump.h
@@ -157,6 +157,7 @@ typedef struct DumpState {
     uint32_t sh_info;
     bool have_section;
     bool resume;
+    bool detached;
     ssize_t note_size;
     hwaddr memory_offset;
     int fd;
-- 
2.12.2

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

* [Qemu-devel] [PULL 14/21] Fix the -accel parameter and the documentation for 'hax'
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (12 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 13/21] dump: Acquire BQL around vm_start() in dump thread Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 15/21] MAINTAINERS: Add "R:" tag for self-appointed reviewers Paolo Bonzini
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Thomas Huth

From: Thomas Huth <thuth@redhat.com>

Since 'hax' is a possible accelerator nowadays, too, the '-accel'
option should support it and we should mention this accelerator
in the documentation, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <1493875481-16388-1-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-options.hx | 18 +++++++++---------
 vl.c            | 23 +++++++++--------------
 2 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index f68829f3b0..70c0ded12e 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -31,7 +31,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
     "-machine [type=]name[,prop[=value][,...]]\n"
     "                selects emulated machine ('-machine help' for list)\n"
     "                property accel=accel1[:accel2[:...]] selects accelerator\n"
-    "                supported accelerators are kvm, xen, tcg (default: tcg)\n"
+    "                supported accelerators are kvm, xen, hax or tcg (default: tcg)\n"
     "                kernel_irqchip=on|off|split controls accelerated irqchip support (default=off)\n"
     "                vmport=on|off|auto controls emulation of vmport (default: auto)\n"
     "                kvm_shadow_mem=size of KVM shadow MMU in bytes\n"
@@ -52,9 +52,9 @@ available machines. Supported machine properties are:
 @table @option
 @item accel=@var{accels1}[:@var{accels2}[:...]]
 This is used to enable an accelerator. Depending on the target architecture,
-kvm, xen, or tcg can be available. By default, tcg is used. If there is more
-than one accelerator specified, the next one is used if the previous one fails
-to initialize.
+kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
+more than one accelerator specified, the next one is used if the previous one
+fails to initialize.
 @item kernel_irqchip=on|off
 Controls in-kernel irqchip support for the chosen accelerator when available.
 @item gfx_passthru=on|off
@@ -97,15 +97,15 @@ ETEXI
 
 DEF("accel", HAS_ARG, QEMU_OPTION_accel,
     "-accel [accel=]accelerator[,thread=single|multi]\n"
-    "               select accelerator ('-accel help for list')\n"
-    "               thread=single|multi (enable multi-threaded TCG)", QEMU_ARCH_ALL)
+    "                select accelerator (kvm, xen, hax or tcg; use 'help' for a list)\n"
+    "                thread=single|multi (enable multi-threaded TCG)", QEMU_ARCH_ALL)
 STEXI
 @item -accel @var{name}[,prop=@var{value}[,...]]
 @findex -accel
 This is used to enable an accelerator. Depending on the target architecture,
-kvm, xen, or tcg can be available. By default, tcg is used. If there is more
-than one accelerator specified, the next one is used if the previous one fails
-to initialize.
+kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
+more than one accelerator specified, the next one is used if the previous one
+fails to initialize.
 @table @option
 @item thread=single|multi
 Controls number of TCG threads. When the TCG is multi-threaded there will be one
diff --git a/vl.c b/vl.c
index 42d4bce439..17b9a8ac2f 100644
--- a/vl.c
+++ b/vl.c
@@ -3727,26 +3727,21 @@ int main(int argc, char **argv, char **envp)
                 qdev_prop_register_global(&kvm_pit_lost_tick_policy);
                 break;
             }
-            case QEMU_OPTION_accel:
+            case QEMU_OPTION_accel: {
+                QemuOpts *accel_opts;
+
                 accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"),
                                                      optarg, true);
                 optarg = qemu_opt_get(accel_opts, "accel");
-
-                olist = qemu_find_opts("machine");
-                if (strcmp("kvm", optarg) == 0) {
-                    qemu_opts_parse_noisily(olist, "accel=kvm", false);
-                } else if (strcmp("xen", optarg) == 0) {
-                    qemu_opts_parse_noisily(olist, "accel=xen", false);
-                } else if (strcmp("tcg", optarg) == 0) {
-                    qemu_opts_parse_noisily(olist, "accel=tcg", false);
-                } else {
-                    if (!is_help_option(optarg)) {
-                        error_printf("Unknown accelerator: %s", optarg);
-                    }
-                    error_printf("Supported accelerators: kvm, xen, tcg\n");
+                if (!optarg || is_help_option(optarg)) {
+                    error_printf("Possible accelerators: kvm, xen, hax, tcg\n");
                     exit(1);
                 }
+                accel_opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
+                                              false, &error_abort);
+                qemu_opt_set(accel_opts, "accel", optarg, &error_abort);
                 break;
+            }
             case QEMU_OPTION_usb:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "usb=on", false);
-- 
2.12.2

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

* [Qemu-devel] [PULL 15/21] MAINTAINERS: Add "R:" tag for self-appointed reviewers
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (13 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 14/21] Fix the -accel parameter and the documentation for 'hax' Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 16/21] get_maintainer: Teach get_maintainer.pl about the new "R:" tag Paolo Bonzini
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul E. McKenney

From: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>

Some people are not content with the amount of mail they get, and would
like to be CCed on patches for areas they do not maintain.  Let them
satisfy their own appetite for qemu-devel messages.

Seriously: the purpose here is a bit different from the Linux kernel.
While Linux uses "R" to designate non-maintainers for reviewing patches
in a given area, in QEMU I would also like to use "R" so that people can
delegate sending pull requests while keeping some degree of oversight.

Based on Linux commit eafbaac3093760d1fd3b2a5b9f016362dd68af36.

Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index a1d2b3a4d3..46cf4870f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12,6 +12,8 @@ consult qemu-devel and not any specific individual privately.
 Descriptions of section entries:
 
 	M: Mail patches to: FullName <address@domain>
+	R: Designated reviewer: FullName <address@domain>
+	   These reviewers should be CCed on patches.
 	L: Mailing list that is relevant to this area
 	W: Web-page with status/info
 	Q: Patchwork web based patch tracking system site
-- 
2.12.2

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

* [Qemu-devel] [PULL 16/21] get_maintainer: Teach get_maintainer.pl about the new "R:" tag
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (14 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 15/21] MAINTAINERS: Add "R:" tag for self-appointed reviewers Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 17/21] get_maintainer: it's '--pattern-depth', not '-pattern-depth' Paolo Bonzini
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joe Perches

From: Joe Perches <joe@perches.com>

We can now designate reviewers in the MAINTAINERS file with the new
"R:" tag, so this commit teaches get_maintainers.pl to add their
email addresses.

Cherry picked from Linux commit c1c3f2c906e35bcb6e4cdf5b8e077660fead14fe,
with fixes to avoid \C as in QEMU commit ba10f729f1 ("get_maintainer.pl:
\C is deprecated", 2015-09-25).

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/get_maintainer.pl | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 8261bcb1ad..c1146ca194 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -21,6 +21,7 @@ my $lk_path = "./";
 my $email = 1;
 my $email_usename = 1;
 my $email_maintainer = 1;
+my $email_reviewer = 1;
 my $email_list = 1;
 my $email_subscriber_list = 0;
 my $email_git = 0;
@@ -180,6 +181,7 @@ if (!GetOptions(
 		'remove-duplicates!' => \$email_remove_duplicates,
 		'mailmap!' => \$email_use_mailmap,
 		'm!' => \$email_maintainer,
+		'r!' => \$email_reviewer,
 		'n!' => \$email_usename,
 		'l!' => \$email_list,
 		's!' => \$email_subscriber_list,
@@ -238,7 +240,8 @@ if ($sections) {
 }
 
 if ($email &&
-    ($email_maintainer + $email_list + $email_subscriber_list +
+    ($email_maintainer + $email_reviewer +
+     $email_list + $email_subscriber_list +
      $email_git + $email_git_blame) == 0) {
     die "$P: Please select at least 1 email option\n";
 }
@@ -718,6 +721,7 @@ MAINTAINER field selection options:
     --hg-since => hg history to use (default: $email_hg_since)
     --interactive => display a menu (mostly useful if used with the --git option)
     --m => include maintainer(s) if any
+    --r => include reviewer(s) if any
     --n => include name 'Full Name <addr\@domain.tld>'
     --l => include list(s) if any
     --s => include subscriber only list(s) if any
@@ -1022,6 +1026,22 @@ sub add_categories {
 		    my $role = get_maintainer_role($i);
 		    push_email_addresses($pvalue, $role);
 		}
+	    } elsif ($ptype eq "R") {
+		my ($name, $address) = parse_email($pvalue);
+		if ($name eq "") {
+		    if ($i > 0) {
+			my $tv = $typevalue[$i - 1];
+			if ($tv =~ m/^(.):\s*(.*)/) {
+			    if ($1 eq "P") {
+				$name = $2;
+				$pvalue = format_email($name, $address, $email_usename);
+			    }
+			}
+		    }
+		}
+		if ($email_reviewer) {
+		    push_email_addresses($pvalue, 'reviewer');
+		}
 	    } elsif ($ptype eq "T") {
 		push(@scm, $pvalue);
 	    } elsif ($ptype eq "W") {
-- 
2.12.2

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

* [Qemu-devel] [PULL 17/21] get_maintainer: it's '--pattern-depth', not '-pattern-depth'
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (15 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 16/21] get_maintainer: Teach get_maintainer.pl about the new "R:" tag Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 18/21] get_maintainer: --r (list reviewer) is on by default Paolo Bonzini
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brian Norris

From: Brian Norris <computersforpeace@gmail.com>

Though it appears that Perl's GetOptions will take either, the latter is
not documented in the options listing.

Cherry picked from Linux commit cc7ff0ef6eca3deeea4a424ca47a67c8450d5424.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/get_maintainer.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index c1146ca194..1f637ff076 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -748,7 +748,7 @@ Other options:
   --help => show this help information
 
 Default options:
-  [--email --nogit --git-fallback --m --n --l --multiline -pattern-depth=0
+  [--email --nogit --git-fallback --m --n --l --multiline --pattern-depth=0
    --remove-duplicates --rolestats]
 
 Notes:
-- 
2.12.2

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

* [Qemu-devel] [PULL 18/21] get_maintainer: --r (list reviewer) is on by default
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (16 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 17/21] get_maintainer: it's '--pattern-depth', not '-pattern-depth' Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 19/21] get_maintainer: add subsystem to reviewer output Paolo Bonzini
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Brian Norris

From: Brian Norris <computersforpeace@gmail.com>

We don't consistenly document the default value next to the option
listing, but we do have a list of defaults here, so let's keep it up to
date.

Cherry picked from Linux commit 4f07510df2e8c47fd65b8ffaaf6c5d334d59d598.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/get_maintainer.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index 1f637ff076..c7cb197a27 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -748,7 +748,7 @@ Other options:
   --help => show this help information
 
 Default options:
-  [--email --nogit --git-fallback --m --n --l --multiline --pattern-depth=0
+  [--email --nogit --git-fallback --m --r --n --l --multiline --pattern-depth=0
    --remove-duplicates --rolestats]
 
 Notes:
-- 
2.12.2

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

* [Qemu-devel] [PULL 19/21] get_maintainer: add subsystem to reviewer output
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (17 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 18/21] get_maintainer: --r (list reviewer) is on by default Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 20/21] libvhost-user: replace vasprintf() to fix build Paolo Bonzini
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joe Perches

From: Joe Perches <joe@perches.com>

Reviewer output currently does not include the subsystem
that matched.  Add it.

Miscellanea:

o Add a get_subsystem_name routine to centralize this

Cherry picked from Linux commit 2a7cb1dc82fc2a52e747b4c496c13f6575fb1790.

Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/get_maintainer.pl | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl
index c7cb197a27..96e66a80a0 100755
--- a/scripts/get_maintainer.pl
+++ b/scripts/get_maintainer.pl
@@ -896,20 +896,29 @@ sub find_ending_index {
     return $index;
 }
 
-sub get_maintainer_role {
+sub get_subsystem_name {
     my ($index) = @_;
 
-    my $i;
     my $start = find_starting_index($index);
-    my $end = find_ending_index($index);
 
-    my $role = "unknown";
     my $subsystem = $typevalue[$start];
     if (length($subsystem) > 20) {
 	$subsystem = substr($subsystem, 0, 17);
 	$subsystem =~ s/\s*$//;
 	$subsystem = $subsystem . "...";
     }
+    return $subsystem;
+}
+
+sub get_maintainer_role {
+    my ($index) = @_;
+
+    my $i;
+    my $start = find_starting_index($index);
+    my $end = find_ending_index($index);
+
+    my $role = "unknown";
+    my $subsystem = get_subsystem_name($index);
 
     for ($i = $start + 1; $i < $end; $i++) {
 	my $tv = $typevalue[$i];
@@ -943,16 +952,7 @@ sub get_maintainer_role {
 sub get_list_role {
     my ($index) = @_;
 
-    my $i;
-    my $start = find_starting_index($index);
-    my $end = find_ending_index($index);
-
-    my $subsystem = $typevalue[$start];
-    if (length($subsystem) > 20) {
-	$subsystem = substr($subsystem, 0, 17);
-	$subsystem =~ s/\s*$//;
-	$subsystem = $subsystem . "...";
-    }
+    my $subsystem = get_subsystem_name($index);
 
     if ($subsystem eq "THE REST") {
 	$subsystem = "";
@@ -1040,7 +1040,8 @@ sub add_categories {
 		    }
 		}
 		if ($email_reviewer) {
-		    push_email_addresses($pvalue, 'reviewer');
+		    my $subsystem = get_subsystem_name($i);
+		    push_email_addresses($pvalue, "reviewer:$subsystem");
 		}
 	    } elsif ($ptype eq "T") {
 		push(@scm, $pvalue);
-- 
2.12.2

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

* [Qemu-devel] [PULL 20/21] libvhost-user: replace vasprintf() to fix build
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (18 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 19/21] get_maintainer: add subsystem to reviewer output Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-05 10:13 ` [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction Paolo Bonzini
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Felipe Franciosi

From: Felipe Franciosi <felipe@nutanix.com>

On gcc 3.4 and newer, simply using (void) in front of WUR functions is
not sufficient to ignore the return value. That prevents a build when
handling warnings as errors.

libvhost-user had a usage of (void)vasprintf() which triggered such a
condition. This fixes it by replacing this call with g_strdup_vprintf()
which aborts on OOM.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Message-Id: <1488479153-21203-2-git-send-email-felipe@nutanix.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 contrib/libvhost-user/libvhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/libvhost-user/libvhost-user.c b/contrib/libvhost-user/libvhost-user.c
index af4faad60b..61e1657e41 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -81,7 +81,7 @@ vu_panic(VuDev *dev, const char *msg, ...)
     va_list ap;
 
     va_start(ap, msg);
-    (void)vasprintf(&buf, msg, ap);
+    buf = g_strdup_vprintf(msg, ap);
     va_end(ap);
 
     dev->broken = true;
-- 
2.12.2

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

* [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (19 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 20/21] libvhost-user: replace vasprintf() to fix build Paolo Bonzini
@ 2017-05-05 10:13 ` Paolo Bonzini
  2017-05-30 13:11   ` Stefan Hajnoczi
  2017-05-08 17:02 ` [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Stefan Hajnoczi
  2017-05-30 13:13 ` Stefan Hajnoczi
  22 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-05 10:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Felipe Franciosi

From: Felipe Franciosi <felipe@nutanix.com>

In order to introduce a new vhost-user-scsi host device type, it makes
sense to abstract part of vhost-scsi into a common parent class. This
commit does exactly that.

Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
Message-Id: <1488479153-21203-3-git-send-email-felipe@nutanix.com>
---
 hw/scsi/Makefile.objs                 |   2 +-
 hw/scsi/vhost-scsi-common.c           | 143 +++++++++++++++++++++++++
 hw/scsi/vhost-scsi.c                  | 194 ++++++++++------------------------
 include/hw/virtio/vhost-scsi-common.h |  48 +++++++++
 include/hw/virtio/vhost-scsi.h        |  11 +-
 include/hw/virtio/virtio-scsi.h       |   2 +
 6 files changed, 252 insertions(+), 148 deletions(-)
 create mode 100644 hw/scsi/vhost-scsi-common.c
 create mode 100644 include/hw/virtio/vhost-scsi-common.h

diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs
index 5a2248be36..54d8754e9a 100644
--- a/hw/scsi/Makefile.objs
+++ b/hw/scsi/Makefile.objs
@@ -10,5 +10,5 @@ obj-$(CONFIG_PSERIES) += spapr_vscsi.o
 
 ifeq ($(CONFIG_VIRTIO),y)
 obj-y += virtio-scsi.o virtio-scsi-dataplane.o
-obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
+obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-common.o vhost-scsi.o
 endif
diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
new file mode 100644
index 0000000000..e41c0314db
--- /dev/null
+++ b/hw/scsi/vhost-scsi-common.c
@@ -0,0 +1,143 @@
+/*
+ * vhost-scsi-common
+ *
+ * Copyright (c) 2016 Nutanix Inc. All rights reserved.
+ *
+ * Author:
+ *  Felipe Franciosi <felipe@nutanix.com>
+ *
+ * This work is largely based on the "vhost-scsi" implementation by:
+ *  Stefan Hajnoczi    <stefanha@linux.vnet.ibm.com>
+ *  Nicholas Bellinger <nab@risingtidesystems.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include <linux/vhost.h>
+#include "qapi/error.h"
+#include "qemu/error-report.h"
+#include "migration/migration.h"
+#include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-scsi-common.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/virtio-bus.h"
+#include "hw/virtio/virtio-access.h"
+#include "hw/fw-path-provider.h"
+
+int vhost_scsi_common_start(VHostSCSICommon *vsc)
+{
+    int ret, i;
+    VirtIODevice *vdev = VIRTIO_DEVICE(vsc);
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+
+    if (!k->set_guest_notifiers) {
+        error_report("binding does not support guest notifiers");
+        return -ENOSYS;
+    }
+
+    ret = vhost_dev_enable_notifiers(&vsc->dev, vdev);
+    if (ret < 0) {
+        return ret;
+    }
+
+    ret = k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, true);
+    if (ret < 0) {
+        error_report("Error binding guest notifier");
+        goto err_host_notifiers;
+    }
+
+    vsc->dev.acked_features = vdev->guest_features;
+    ret = vhost_dev_start(&vsc->dev, vdev);
+    if (ret < 0) {
+        error_report("Error start vhost dev");
+        goto err_guest_notifiers;
+    }
+
+    /* guest_notifier_mask/pending not used yet, so just unmask
+     * everything here.  virtio-pci will do the right thing by
+     * enabling/disabling irqfd.
+     */
+    for (i = 0; i < vsc->dev.nvqs; i++) {
+        vhost_virtqueue_mask(&vsc->dev, vdev, vsc->dev.vq_index + i, false);
+    }
+
+    return ret;
+
+err_guest_notifiers:
+    k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false);
+err_host_notifiers:
+    vhost_dev_disable_notifiers(&vsc->dev, vdev);
+    return ret;
+}
+
+void vhost_scsi_common_stop(VHostSCSICommon *vsc)
+{
+    VirtIODevice *vdev = VIRTIO_DEVICE(vsc);
+    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
+    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
+    int ret = 0;
+
+    vhost_dev_stop(&vsc->dev, vdev);
+
+    if (k->set_guest_notifiers) {
+        ret = k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false);
+        if (ret < 0) {
+                error_report("vhost guest notifier cleanup failed: %d", ret);
+        }
+    }
+    assert(ret >= 0);
+
+    vhost_dev_disable_notifiers(&vsc->dev, vdev);
+}
+
+uint64_t vhost_scsi_common_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp)
+{
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(vdev);
+
+    return vhost_get_features(&vsc->dev, vsc->feature_bits, features);
+}
+
+void vhost_scsi_common_set_config(VirtIODevice *vdev, const uint8_t *config)
+{
+    VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
+    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+
+    if ((uint32_t)virtio_ldl_p(vdev, &scsiconf->sense_size) != vs->sense_size ||
+        (uint32_t)virtio_ldl_p(vdev, &scsiconf->cdb_size) != vs->cdb_size) {
+        error_report("vhost-scsi does not support changing the sense data and "
+                     "CDB sizes");
+        exit(1);
+    }
+}
+
+/*
+ * Implementation of an interface to adjust firmware path
+ * for the bootindex property handling.
+ */
+char *vhost_scsi_common_get_fw_dev_path(FWPathProvider *p, BusState *bus,
+                                        DeviceState *dev)
+{
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev);
+    /* format: /channel@channel/vhost-scsi@target,lun */
+    return g_strdup_printf("/channel@%x/%s@%x,%x", vsc->channel,
+                           qdev_fw_name(dev), vsc->target, vsc->lun);
+}
+
+static const TypeInfo vhost_scsi_common_info = {
+    .name = TYPE_VHOST_SCSI_COMMON,
+    .parent = TYPE_VIRTIO_SCSI_COMMON,
+    .instance_size = sizeof(VHostSCSICommon),
+    .abstract = true,
+};
+
+static void virtio_register_types(void)
+{
+    type_register_static(&vhost_scsi_common_info);
+}
+
+type_init(virtio_register_types)
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index f53bc179da..8f53ac3795 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -42,13 +42,14 @@ static const int kernel_feature_bits[] = {
 static int vhost_scsi_set_endpoint(VHostSCSI *s)
 {
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
-    const VhostOps *vhost_ops = s->dev.vhost_ops;
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+    const VhostOps *vhost_ops = vsc->dev.vhost_ops;
     struct vhost_scsi_target backend;
     int ret;
 
     memset(&backend, 0, sizeof(backend));
     pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
-    ret = vhost_ops->vhost_scsi_set_endpoint(&s->dev, &backend);
+    ret = vhost_ops->vhost_scsi_set_endpoint(&vsc->dev, &backend);
     if (ret < 0) {
         return -errno;
     }
@@ -58,130 +59,62 @@ static int vhost_scsi_set_endpoint(VHostSCSI *s)
 static void vhost_scsi_clear_endpoint(VHostSCSI *s)
 {
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
     struct vhost_scsi_target backend;
-    const VhostOps *vhost_ops = s->dev.vhost_ops;
+    const VhostOps *vhost_ops = vsc->dev.vhost_ops;
 
     memset(&backend, 0, sizeof(backend));
     pstrcpy(backend.vhost_wwpn, sizeof(backend.vhost_wwpn), vs->conf.wwpn);
-    vhost_ops->vhost_scsi_clear_endpoint(&s->dev, &backend);
+    vhost_ops->vhost_scsi_clear_endpoint(&vsc->dev, &backend);
 }
 
 static int vhost_scsi_start(VHostSCSI *s)
 {
-    int ret, abi_version, i;
-    VirtIODevice *vdev = VIRTIO_DEVICE(s);
-    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
-    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
-    const VhostOps *vhost_ops = s->dev.vhost_ops;
-
-    if (!k->set_guest_notifiers) {
-        error_report("binding does not support guest notifiers");
-        return -ENOSYS;
-    }
+    int ret, abi_version;
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+    const VhostOps *vhost_ops = vsc->dev.vhost_ops;
 
-    ret = vhost_ops->vhost_scsi_get_abi_version(&s->dev, &abi_version);
+    ret = vhost_ops->vhost_scsi_get_abi_version(&vsc->dev, &abi_version);
     if (ret < 0) {
         return -errno;
     }
     if (abi_version > VHOST_SCSI_ABI_VERSION) {
         error_report("vhost-scsi: The running tcm_vhost kernel abi_version:"
-                     " %d is greater than vhost_scsi userspace supports: %d, please"
-                     " upgrade your version of QEMU", abi_version,
+                     " %d is greater than vhost_scsi userspace supports: %d,"
+                     " please upgrade your version of QEMU", abi_version,
                      VHOST_SCSI_ABI_VERSION);
         return -ENOSYS;
     }
 
-    ret = vhost_dev_enable_notifiers(&s->dev, vdev);
+    ret = vhost_scsi_common_start(vsc);
     if (ret < 0) {
         return ret;
     }
 
-    s->dev.acked_features = vdev->guest_features;
-    ret = vhost_dev_start(&s->dev, vdev);
-    if (ret < 0) {
-        error_report("Error start vhost dev");
-        goto err_notifiers;
-    }
-
     ret = vhost_scsi_set_endpoint(s);
     if (ret < 0) {
-        error_report("Error set vhost-scsi endpoint");
-        goto err_vhost_stop;
-    }
-
-    ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, true);
-    if (ret < 0) {
-        error_report("Error binding guest notifier");
-        goto err_endpoint;
-    }
-
-    /* guest_notifier_mask/pending not used yet, so just unmask
-     * everything here.  virtio-pci will do the right thing by
-     * enabling/disabling irqfd.
-     */
-    for (i = 0; i < s->dev.nvqs; i++) {
-        vhost_virtqueue_mask(&s->dev, vdev, s->dev.vq_index + i, false);
+        error_report("Error setting vhost-scsi endpoint");
+        vhost_scsi_common_stop(vsc);
     }
 
     return ret;
-
-err_endpoint:
-    vhost_scsi_clear_endpoint(s);
-err_vhost_stop:
-    vhost_dev_stop(&s->dev, vdev);
-err_notifiers:
-    vhost_dev_disable_notifiers(&s->dev, vdev);
-    return ret;
 }
 
 static void vhost_scsi_stop(VHostSCSI *s)
 {
-    VirtIODevice *vdev = VIRTIO_DEVICE(s);
-    BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev)));
-    VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
-    int ret = 0;
-
-    if (k->set_guest_notifiers) {
-        ret = k->set_guest_notifiers(qbus->parent, s->dev.nvqs, false);
-        if (ret < 0) {
-                error_report("vhost guest notifier cleanup failed: %d", ret);
-        }
-    }
-    assert(ret >= 0);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
 
     vhost_scsi_clear_endpoint(s);
-    vhost_dev_stop(&s->dev, vdev);
-    vhost_dev_disable_notifiers(&s->dev, vdev);
-}
-
-static uint64_t vhost_scsi_get_features(VirtIODevice *vdev,
-                                        uint64_t features,
-                                        Error **errp)
-{
-    VHostSCSI *s = VHOST_SCSI(vdev);
-
-    return vhost_get_features(&s->dev, kernel_feature_bits, features);
-}
-
-static void vhost_scsi_set_config(VirtIODevice *vdev,
-                                  const uint8_t *config)
-{
-    VirtIOSCSIConfig *scsiconf = (VirtIOSCSIConfig *)config;
-    VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
-
-    if ((uint32_t) virtio_ldl_p(vdev, &scsiconf->sense_size) != vs->sense_size ||
-        (uint32_t) virtio_ldl_p(vdev, &scsiconf->cdb_size) != vs->cdb_size) {
-        error_report("vhost-scsi does not support changing the sense data and CDB sizes");
-        exit(1);
-    }
+    vhost_scsi_common_stop(vsc);
 }
 
 static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
 {
-    VHostSCSI *s = (VHostSCSI *)vdev;
+    VHostSCSI *s = VHOST_SCSI(vdev);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
     bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK);
 
-    if (s->dev.started == start) {
+    if (vsc->dev.started == start) {
         return;
     }
 
@@ -190,10 +123,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
 
         ret = vhost_scsi_start(s);
         if (ret < 0) {
-            error_report("virtio-scsi: unable to start vhost: %s",
-                         strerror(-ret));
-
-            /* There is no userspace virtio-scsi fallback so exit */
+            error_report("unable to start vhost-scsi: %s", strerror(-ret));
             exit(1);
         }
     } else {
@@ -208,7 +138,7 @@ static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 static void vhost_scsi_realize(DeviceState *dev, Error **errp)
 {
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
-    VHostSCSI *s = VHOST_SCSI(dev);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev);
     Error *err = NULL;
     int vhostfd = -1;
     int ret;
@@ -243,21 +173,21 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
         goto close_fd;
     }
 
-    error_setg(&s->migration_blocker,
+    error_setg(&vsc->migration_blocker,
                "vhost-scsi does not support migration");
-    migrate_add_blocker(s->migration_blocker, &err);
+    migrate_add_blocker(vsc->migration_blocker, &err);
     if (err) {
         error_propagate(errp, err);
-        error_free(s->migration_blocker);
+        error_free(vsc->migration_blocker);
         goto close_fd;
     }
 
-    s->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
-    s->dev.vqs = g_new(struct vhost_virtqueue, s->dev.nvqs);
-    s->dev.vq_index = 0;
-    s->dev.backend_features = 0;
+    vsc->dev.nvqs = VHOST_SCSI_VQ_NUM_FIXED + vs->conf.num_queues;
+    vsc->dev.vqs = g_new(struct vhost_virtqueue, vsc->dev.nvqs);
+    vsc->dev.vq_index = 0;
+    vsc->dev.backend_features = 0;
 
-    ret = vhost_dev_init(&s->dev, (void *)(uintptr_t)vhostfd,
+    ret = vhost_dev_init(&vsc->dev, (void *)(uintptr_t)vhostfd,
                          VHOST_BACKEND_TYPE_KERNEL, 0);
     if (ret < 0) {
         error_setg(errp, "vhost-scsi: vhost initialization failed: %s",
@@ -266,16 +196,16 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
     }
 
     /* At present, channel and lun both are 0 for bootable vhost-scsi disk */
-    s->channel = 0;
-    s->lun = 0;
+    vsc->channel = 0;
+    vsc->lun = 0;
     /* Note: we can also get the minimum tpgt from kernel */
-    s->target = vs->conf.boot_tpgt;
+    vsc->target = vs->conf.boot_tpgt;
 
     return;
 
  free_vqs:
-    migrate_del_blocker(s->migration_blocker);
-    g_free(s->dev.vqs);
+    migrate_del_blocker(vsc->migration_blocker);
+    g_free(vsc->dev.vqs);
  close_fd:
     close(vhostfd);
     return;
@@ -284,42 +214,28 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
 static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
-    VHostSCSI *s = VHOST_SCSI(dev);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(dev);
 
-    migrate_del_blocker(s->migration_blocker);
-    error_free(s->migration_blocker);
+    migrate_del_blocker(vsc->migration_blocker);
+    error_free(vsc->migration_blocker);
 
     /* This will stop vhost backend. */
     vhost_scsi_set_status(vdev, 0);
 
-    vhost_dev_cleanup(&s->dev);
-    g_free(s->dev.vqs);
+    vhost_dev_cleanup(&vsc->dev);
+    g_free(vsc->dev.vqs);
 
     virtio_scsi_common_unrealize(dev, errp);
 }
 
-/*
- * Implementation of an interface to adjust firmware path
- * for the bootindex property handling.
- */
-static char *vhost_scsi_get_fw_dev_path(FWPathProvider *p, BusState *bus,
-                                        DeviceState *dev)
-{
-    VHostSCSI *s = VHOST_SCSI(dev);
-    /* format: channel@channel/vhost-scsi@target,lun */
-    return g_strdup_printf("/channel@%x/%s@%x,%x", s->channel,
-                           qdev_fw_name(dev), s->target, s->lun);
-}
-
 static Property vhost_scsi_properties[] = {
-    DEFINE_PROP_STRING("vhostfd", VHostSCSI, parent_obj.conf.vhostfd),
-    DEFINE_PROP_STRING("wwpn", VHostSCSI, parent_obj.conf.wwpn),
-    DEFINE_PROP_UINT32("boot_tpgt", VHostSCSI, parent_obj.conf.boot_tpgt, 0),
-    DEFINE_PROP_UINT32("num_queues", VHostSCSI, parent_obj.conf.num_queues, 1),
-    DEFINE_PROP_UINT32("max_sectors", VHostSCSI, parent_obj.conf.max_sectors,
-                                                 0xFFFF),
-    DEFINE_PROP_UINT32("cmd_per_lun", VHostSCSI, parent_obj.conf.cmd_per_lun,
-                                                 128),
+    DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd),
+    DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn),
+    DEFINE_PROP_UINT32("boot_tpgt", VirtIOSCSICommon, conf.boot_tpgt, 0),
+    DEFINE_PROP_UINT32("num_queues", VirtIOSCSICommon, conf.num_queues, 1),
+    DEFINE_PROP_UINT32("max_sectors", VirtIOSCSICommon, conf.max_sectors,
+                       0xFFFF),
+    DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSICommon, conf.cmd_per_lun, 128),
     DEFINE_PROP_END_OF_LIST(),
 };
 
@@ -333,23 +249,25 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data)
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     vdc->realize = vhost_scsi_realize;
     vdc->unrealize = vhost_scsi_unrealize;
-    vdc->get_features = vhost_scsi_get_features;
-    vdc->set_config = vhost_scsi_set_config;
+    vdc->get_features = vhost_scsi_common_get_features;
+    vdc->set_config = vhost_scsi_common_set_config;
     vdc->set_status = vhost_scsi_set_status;
-    fwc->get_dev_path = vhost_scsi_get_fw_dev_path;
+    fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path;
 }
 
 static void vhost_scsi_instance_init(Object *obj)
 {
-    VHostSCSI *dev = VHOST_SCSI(obj);
+    VHostSCSICommon *vsc = VHOST_SCSI_COMMON(obj);
+
+    vsc->feature_bits = kernel_feature_bits;
 
-    device_add_bootindex_property(obj, &dev->bootindex, "bootindex", NULL,
-                                  DEVICE(dev), NULL);
+    device_add_bootindex_property(obj, &vsc->bootindex, "bootindex", NULL,
+                                  DEVICE(vsc), NULL);
 }
 
 static const TypeInfo vhost_scsi_info = {
     .name = TYPE_VHOST_SCSI,
-    .parent = TYPE_VIRTIO_SCSI_COMMON,
+    .parent = TYPE_VHOST_SCSI_COMMON,
     .instance_size = sizeof(VHostSCSI),
     .class_init = vhost_scsi_class_init,
     .instance_init = vhost_scsi_instance_init,
diff --git a/include/hw/virtio/vhost-scsi-common.h b/include/hw/virtio/vhost-scsi-common.h
new file mode 100644
index 0000000000..4553be4bc3
--- /dev/null
+++ b/include/hw/virtio/vhost-scsi-common.h
@@ -0,0 +1,48 @@
+/*
+ * vhost_scsi host device
+ *
+ * Copyright (c) 2016 Nutanix Inc. All rights reserved.
+ *
+ * Author:
+ *  Felipe Franciosi <felipe@nutanix.com>
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#ifndef VHOST_SCSI_COMMON_H
+#define VHOST_SCSI_COMMON_H
+
+#include "qemu-common.h"
+#include "hw/qdev.h"
+#include "hw/virtio/virtio-scsi.h"
+#include "hw/virtio/vhost.h"
+#include "hw/fw-path-provider.h"
+
+#define TYPE_VHOST_SCSI_COMMON "vhost-scsi-common"
+#define VHOST_SCSI_COMMON(obj) \
+        OBJECT_CHECK(VHostSCSICommon, (obj), TYPE_VHOST_SCSI_COMMON)
+
+typedef struct VHostSCSICommon {
+    VirtIOSCSICommon parent_obj;
+
+    Error *migration_blocker;
+
+    struct vhost_dev dev;
+    const int *feature_bits;
+    int32_t bootindex;
+    int channel;
+    int target;
+    int lun;
+} VHostSCSICommon;
+
+int vhost_scsi_common_start(VHostSCSICommon *vsc);
+void vhost_scsi_common_stop(VHostSCSICommon *vsc);
+char *vhost_scsi_common_get_fw_dev_path(FWPathProvider *p, BusState *bus,
+                                        DeviceState *dev);
+void vhost_scsi_common_set_config(VirtIODevice *vdev, const uint8_t *config);
+uint64_t vhost_scsi_common_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp);
+
+#endif /* VHOST_SCSI_COMMON_H */
diff --git a/include/hw/virtio/vhost-scsi.h b/include/hw/virtio/vhost-scsi.h
index 9fd63df12e..04658d14f5 100644
--- a/include/hw/virtio/vhost-scsi.h
+++ b/include/hw/virtio/vhost-scsi.h
@@ -18,6 +18,7 @@
 #include "hw/qdev.h"
 #include "hw/virtio/virtio-scsi.h"
 #include "hw/virtio/vhost.h"
+#include "hw/virtio/vhost-scsi-common.h"
 
 enum vhost_scsi_vq_list {
     VHOST_SCSI_VQ_CONTROL = 0,
@@ -30,15 +31,7 @@ enum vhost_scsi_vq_list {
         OBJECT_CHECK(VHostSCSI, (obj), TYPE_VHOST_SCSI)
 
 typedef struct VHostSCSI {
-    VirtIOSCSICommon parent_obj;
-
-    Error *migration_blocker;
-
-    struct vhost_dev dev;
-    int32_t bootindex;
-    int channel;
-    int target;
-    int lun;
+    VHostSCSICommon parent_obj;
 } VHostSCSI;
 
 #endif
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index 8c8453cf19..eac2013ddd 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -49,8 +49,10 @@ struct VirtIOSCSIConf {
     uint32_t num_queues;
     uint32_t max_sectors;
     uint32_t cmd_per_lun;
+#ifdef CONFIG_VHOST_SCSI
     char *vhostfd;
     char *wwpn;
+#endif
     uint32_t boot_tpgt;
     IOThread *iothread;
 };
-- 
2.12.2

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

* Re: [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (20 preceding siblings ...)
  2017-05-05 10:13 ` [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction Paolo Bonzini
@ 2017-05-08 17:02 ` Stefan Hajnoczi
  2017-05-30 13:13 ` Stefan Hajnoczi
  22 siblings, 0 replies; 30+ messages in thread
From: Stefan Hajnoczi @ 2017-05-08 17:02 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 5645 bytes --]

On Fri, May 05, 2017 at 12:13:16PM +0200, Paolo Bonzini wrote:
> The following changes since commit e619b14746e5d8c0e53061661fd0e1da01fd4d60:
> 
>   Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging (2017-05-02 15:16:29 +0100)
> 
> are available in the git repository at:
> 
>   git://github.com/bonzini/qemu.git tags/for-upstream
> 
> for you to fetch changes up to 95615ce5a1beffff1a5dd3597d8cb6ba83f0010e:
> 
>   vhost-scsi: create a vhost-scsi-common abstraction (2017-05-05 12:10:00 +0200)
> 
> ----------------------------------------------------------------
> A large set of small patches.  I have not included yet vhost-user-scsi,
> but it'll come in the next pull request.
> 
> * use GDB XML register description for x86
> * use _Static_assert in QEMU_BUILD_BUG_ON
> * add "R:" to MAINTAINERS and get_maintainers
> * checkpatch improvements
> * dump threading fixes
> * first part of vhost-user-scsi support
> * QemuMutex tracing
> * vmw_pvscsi and megasas fixes
> * sgabios module update
> * use Rev3 (ACPI 2.0) FADT
> * deprecate -hdachs
> * improve -accel documentation
> * hax fix
> * qemu-char GSource bugfix
> 
> ----------------------------------------------------------------
> Abdallah Bouassida (1):
>       target/i386: Add GDB XML register description support
> 
> Andreas Grapentin (1):
>       use _Static_assert in QEMU_BUILD_BUG_ON
> 
> Brian Norris (2):
>       get_maintainer: it's '--pattern-depth', not '-pattern-depth'
>       get_maintainer: --r (list reviewer) is on by default
> 
> Dr. David Alan Gilbert (1):
>       checkpatch: Disallow glib asserts in main code
> 
> Fam Zheng (1):
>       dump: Acquire BQL around vm_start() in dump thread
> 
> Felipe Franciosi (2):
>       libvhost-user: replace vasprintf() to fix build
>       vhost-scsi: create a vhost-scsi-common abstraction
> 
> Joe Perches (2):
>       get_maintainer: Teach get_maintainer.pl about the new "R:" tag
>       get_maintainer: add subsystem to reviewer output
> 
> Jose Ricardo Ziviani (1):
>       trace: add qemu mutex lock and unlock trace events
> 
> P J P (1):
>       vmw_pvscsi: check message ring page count at initialisation
> 
> Paolo Bonzini (1):
>       sgabios: update for "fix wrong video attrs for int 10h,ah==13h"
> 
> Paul E. McKenney (1):
>       MAINTAINERS: Add "R:" tag for self-appointed reviewers
> 
> Phil Dennis-Jordan (2):
>       hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support.
>       hw/i386: Build-time assertion on pc/q35 reset register being identical.
> 
> Prasad J Pandit (1):
>       scsi: avoid an off-by-one error in megasas_mmio_write
> 
> Thomas Huth (2):
>       vl: deprecate the "-hdachs" option
>       Fix the -accel parameter and the documentation for 'hax'
> 
> Yu Ning (1):
>       hax: Fix memory mapping de-duplication logic
> 
> zhanghailiang (1):
>       char: Fix removing wrong GSource that be found by fd_in_tag
> 
>  MAINTAINERS                           |   2 +
>  chardev/char-fd.c                     |   8 +-
>  chardev/char-io.c                     |  23 ++--
>  chardev/char-io.h                     |   4 +-
>  chardev/char-pty.c                    |   6 +-
>  chardev/char-socket.c                 |   8 +-
>  chardev/char-udp.c                    |   8 +-
>  chardev/char.c                        |   2 +-
>  configure                             |  20 ++++
>  contrib/libvhost-user/libvhost-user.c |   2 +-
>  dump.c                                |   7 ++
>  gdb-xml/i386-32bit-core.xml           |  65 ++++++++++++
>  gdb-xml/i386-64bit-core.xml           |  73 +++++++++++++
>  hw/i386/acpi-build.c                  |  35 +++++-
>  hw/pci-host/piix.c                    |   6 --
>  hw/scsi/Makefile.objs                 |   2 +-
>  hw/scsi/megasas.c                     |  10 +-
>  hw/scsi/vhost-scsi-common.c           | 143 +++++++++++++++++++++++++
>  hw/scsi/vhost-scsi.c                  | 194 ++++++++++------------------------
>  hw/scsi/vmw_pvscsi.c                  |   2 +-
>  include/hw/acpi/acpi-defs.h           |  77 +++++++-------
>  include/hw/i386/pc.h                  |   6 ++
>  include/hw/virtio/vhost-scsi-common.h |  48 +++++++++
>  include/hw/virtio/vhost-scsi.h        |  11 +-
>  include/hw/virtio/virtio-scsi.h       |   2 +
>  include/qemu/compiler.h               |   4 +-
>  include/sysemu/char.h                 |   2 +-
>  include/sysemu/dump.h                 |   1 +
>  pc-bios/sgabios.bin                   | Bin 4096 -> 4096 bytes
>  qemu-options.hx                       |  22 ++--
>  roms/sgabios                          |   2 +-
>  scripts/checkpatch.pl                 |  21 ++++
>  scripts/get_maintainer.pl             |  53 +++++++---
>  target/i386/cpu.c                     |  21 +++-
>  target/i386/hax-mem.c                 |  19 +++-
>  tests/acpi-utils.h                    |  10 ++
>  tests/bios-tables-test.c              |  23 +++-
>  util/qemu-thread-posix.c              |  18 +++-
>  util/qemu-thread-win32.c              |  11 +-
>  util/trace-events                     |   4 +
>  vl.c                                  |  25 ++---
>  41 files changed, 705 insertions(+), 295 deletions(-)
>  create mode 100644 gdb-xml/i386-32bit-core.xml
>  create mode 100644 gdb-xml/i386-64bit-core.xml
>  create mode 100644 hw/scsi/vhost-scsi-common.c
>  create mode 100644 include/hw/virtio/vhost-scsi-common.h
> -- 
> 2.12.2
> 
> 

Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-05 10:13 ` [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction Paolo Bonzini
@ 2017-05-30 13:11   ` Stefan Hajnoczi
  2017-05-30 14:06     ` Felipe Franciosi
  0 siblings, 1 reply; 30+ messages in thread
From: Stefan Hajnoczi @ 2017-05-30 13:11 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Felipe Franciosi

[-- Attachment #1: Type: text/plain, Size: 2397 bytes --]

On Fri, May 05, 2017 at 12:13:37PM +0200, Paolo Bonzini wrote:
> From: Felipe Franciosi <felipe@nutanix.com>
> 
> In order to introduce a new vhost-user-scsi host device type, it makes
> sense to abstract part of vhost-scsi into a common parent class. This
> commit does exactly that.
> 
> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
> Message-Id: <1488479153-21203-3-git-send-email-felipe@nutanix.com>
> ---
>  hw/scsi/Makefile.objs                 |   2 +-
>  hw/scsi/vhost-scsi-common.c           | 143 +++++++++++++++++++++++++
>  hw/scsi/vhost-scsi.c                  | 194 ++++++++++------------------------
>  include/hw/virtio/vhost-scsi-common.h |  48 +++++++++
>  include/hw/virtio/vhost-scsi.h        |  11 +-
>  include/hw/virtio/virtio-scsi.h       |   2 +
>  6 files changed, 252 insertions(+), 148 deletions(-)
>  create mode 100644 hw/scsi/vhost-scsi-common.c
>  create mode 100644 include/hw/virtio/vhost-scsi-common.h
> 
> diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs
> index 5a2248be36..54d8754e9a 100644
> --- a/hw/scsi/Makefile.objs
> +++ b/hw/scsi/Makefile.objs
> @@ -10,5 +10,5 @@ obj-$(CONFIG_PSERIES) += spapr_vscsi.o
>  
>  ifeq ($(CONFIG_VIRTIO),y)
>  obj-y += virtio-scsi.o virtio-scsi-dataplane.o
> -obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
> +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-common.o vhost-scsi.o
>  endif
> diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
> new file mode 100644
> index 0000000000..e41c0314db
> --- /dev/null
> +++ b/hw/scsi/vhost-scsi-common.c
> @@ -0,0 +1,143 @@
> +/*
> + * vhost-scsi-common
> + *
> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.
> + *
> + * Author:
> + *  Felipe Franciosi <felipe@nutanix.com>
> + *
> + * This work is largely based on the "vhost-scsi" implementation by:
> + *  Stefan Hajnoczi    <stefanha@linux.vnet.ibm.com>
> + *  Nicholas Bellinger <nab@risingtidesystems.com>
> + *
> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
> + * See the COPYING.LIB file in the top-level directory.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include <linux/vhost.h>

This breaks the mingw build:

  hw/scsi/vhost-scsi-common.c:19:25: fatal error: linux/vhost.h: No such file or directory
   #include <linux/vhost.h>
                         ^
  compilation terminated.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Re: [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05
  2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
                   ` (21 preceding siblings ...)
  2017-05-08 17:02 ` [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Stefan Hajnoczi
@ 2017-05-30 13:13 ` Stefan Hajnoczi
  22 siblings, 0 replies; 30+ messages in thread
From: Stefan Hajnoczi @ 2017-05-30 13:13 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1349 bytes --]

On Fri, May 05, 2017 at 12:13:16PM +0200, Paolo Bonzini wrote:
> The following changes since commit e619b14746e5d8c0e53061661fd0e1da01fd4d60:
> 
>   Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging (2017-05-02 15:16:29 +0100)
> 
> are available in the git repository at:
> 
>   git://github.com/bonzini/qemu.git tags/for-upstream
> 
> for you to fetch changes up to 95615ce5a1beffff1a5dd3597d8cb6ba83f0010e:
> 
>   vhost-scsi: create a vhost-scsi-common abstraction (2017-05-05 12:10:00 +0200)
> 
> ----------------------------------------------------------------
> A large set of small patches.  I have not included yet vhost-user-scsi,
> but it'll come in the next pull request.
> 
> * use GDB XML register description for x86
> * use _Static_assert in QEMU_BUILD_BUG_ON
> * add "R:" to MAINTAINERS and get_maintainers
> * checkpatch improvements
> * dump threading fixes
> * first part of vhost-user-scsi support
> * QemuMutex tracing
> * vmw_pvscsi and megasas fixes
> * sgabios module update
> * use Rev3 (ACPI 2.0) FADT
> * deprecate -hdachs
> * improve -accel documentation
> * hax fix
> * qemu-char GSource bugfix

I had to drop this pull request because vhost-user-scsi breaks the mingw
build.  I've replied to the patch in question with the detailed compiler
message.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-30 13:11   ` Stefan Hajnoczi
@ 2017-05-30 14:06     ` Felipe Franciosi
  2017-05-30 14:16       ` Paolo Bonzini
  0 siblings, 1 reply; 30+ messages in thread
From: Felipe Franciosi @ 2017-05-30 14:06 UTC (permalink / raw)
  To: Stefan Hajnoczi, Paolo Bonzini; +Cc: qemu-devel


> On 30 May 2017, at 14:11, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> 
> On Fri, May 05, 2017 at 12:13:37PM +0200, Paolo Bonzini wrote:
>> From: Felipe Franciosi <felipe@nutanix.com>
>> 
>> In order to introduce a new vhost-user-scsi host device type, it makes
>> sense to abstract part of vhost-scsi into a common parent class. This
>> commit does exactly that.
>> 
>> Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
>> Message-Id: <1488479153-21203-3-git-send-email-felipe@nutanix.com>
>> ---
>> hw/scsi/Makefile.objs                 |   2 +-
>> hw/scsi/vhost-scsi-common.c           | 143 +++++++++++++++++++++++++
>> hw/scsi/vhost-scsi.c                  | 194 ++++++++++------------------------
>> include/hw/virtio/vhost-scsi-common.h |  48 +++++++++
>> include/hw/virtio/vhost-scsi.h        |  11 +-
>> include/hw/virtio/virtio-scsi.h       |   2 +
>> 6 files changed, 252 insertions(+), 148 deletions(-)
>> create mode 100644 hw/scsi/vhost-scsi-common.c
>> create mode 100644 include/hw/virtio/vhost-scsi-common.h
>> 
>> diff --git a/hw/scsi/Makefile.objs b/hw/scsi/Makefile.objs
>> index 5a2248be36..54d8754e9a 100644
>> --- a/hw/scsi/Makefile.objs
>> +++ b/hw/scsi/Makefile.objs
>> @@ -10,5 +10,5 @@ obj-$(CONFIG_PSERIES) += spapr_vscsi.o
>> 
>> ifeq ($(CONFIG_VIRTIO),y)
>> obj-y += virtio-scsi.o virtio-scsi-dataplane.o
>> -obj-$(CONFIG_VHOST_SCSI) += vhost-scsi.o
>> +obj-$(CONFIG_VHOST_SCSI) += vhost-scsi-common.o vhost-scsi.o
>> endif
>> diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
>> new file mode 100644
>> index 0000000000..e41c0314db
>> --- /dev/null
>> +++ b/hw/scsi/vhost-scsi-common.c
>> @@ -0,0 +1,143 @@
>> +/*
>> + * vhost-scsi-common
>> + *
>> + * Copyright (c) 2016 Nutanix Inc. All rights reserved.
>> + *
>> + * Author:
>> + *  Felipe Franciosi <felipe@nutanix.com>
>> + *
>> + * This work is largely based on the "vhost-scsi" implementation by:
>> + *  Stefan Hajnoczi    <stefanha@linux.vnet.ibm.com>
>> + *  Nicholas Bellinger <nab@risingtidesystems.com>
>> + *
>> + * This work is licensed under the terms of the GNU LGPL, version 2 or later.
>> + * See the COPYING.LIB file in the top-level directory.
>> + *
>> + */
>> +
>> +#include "qemu/osdep.h"
>> +#include <linux/vhost.h>
> 
> This breaks the mingw build:
> 
>  hw/scsi/vhost-scsi-common.c:19:25: fatal error: linux/vhost.h: No such file or directory
>   #include <linux/vhost.h>
>                         ^
>  compilation terminated.

Thanks for the report.

Paolo: I know you wanted this enabled by default whenever virtio was built, but maybe we should stick to a configure switch live vhost-net, vhost-scsi and vhost-vsock?

Let me know what you think and I'll send an extra patch for it straight away.

Felipe

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-30 14:06     ` Felipe Franciosi
@ 2017-05-30 14:16       ` Paolo Bonzini
  2017-05-30 14:21         ` Felipe Franciosi
  0 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-30 14:16 UTC (permalink / raw)
  To: Felipe Franciosi, Stefan Hajnoczi; +Cc: qemu-devel



On 30/05/2017 16:06, Felipe Franciosi wrote:
>> This breaks the mingw build:
>>
>>  hw/scsi/vhost-scsi-common.c:19:25: fatal error: linux/vhost.h: No such file or directory
>>   #include <linux/vhost.h>
>>                         ^
>>  compilation terminated.
> Thanks for the report.
> 
> Paolo: I know you wanted this enabled by default whenever virtio was built, but maybe we should stick to a configure switch live vhost-net, vhost-scsi and vhost-vsock?
> 
> Let me know what you think and I'll send an extra patch for it straight away.

This was my mistake.  Your patch broke s390, and when I fixed it I
copied the wrong setting:

default-configs/pci.mak:CONFIG_VHOST_USER_SCSI=$(CONFIG_POSIX)
default-configs/s390x-softmmu.mak:CONFIG_VHOST_USER_SCSI=y

Unfortunately, the mingw docker test doesn't build all targets, so I
missed it.

I would like vhost-user to be available on non-Linux POSIX, but this is
not immediately possible because vhost-backend.c includes the kernel
backend.  So we'll have to change CONFIG_POSIX to CONFIG_LINUX too.

Paolo

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-30 14:16       ` Paolo Bonzini
@ 2017-05-30 14:21         ` Felipe Franciosi
  2017-05-30 14:29           ` Paolo Bonzini
  0 siblings, 1 reply; 30+ messages in thread
From: Felipe Franciosi @ 2017-05-30 14:21 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Stefan Hajnoczi, qemu-devel


> On 30 May 2017, at 15:16, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> 
> 
> On 30/05/2017 16:06, Felipe Franciosi wrote:
>>> This breaks the mingw build:
>>> 
>>> hw/scsi/vhost-scsi-common.c:19:25: fatal error: linux/vhost.h: No such file or directory
>>>  #include <linux/vhost.h>
>>>                        ^
>>> compilation terminated.
>> Thanks for the report.
>> 
>> Paolo: I know you wanted this enabled by default whenever virtio was built, but maybe we should stick to a configure switch live vhost-net, vhost-scsi and vhost-vsock?
>> 
>> Let me know what you think and I'll send an extra patch for it straight away.
> 
> This was my mistake.  Your patch broke s390, and when I fixed it I
> copied the wrong setting:
> 
> default-configs/pci.mak:CONFIG_VHOST_USER_SCSI=$(CONFIG_POSIX)
> default-configs/s390x-softmmu.mak:CONFIG_VHOST_USER_SCSI=y
> 
> Unfortunately, the mingw docker test doesn't build all targets, so I
> missed it.
> 
> I would like vhost-user to be available on non-Linux POSIX, but this is
> not immediately possible because vhost-backend.c includes the kernel
> backend.  So we'll have to change CONFIG_POSIX to CONFIG_LINUX too.

Sounds good to me. Do you need anything from my end or are you happy to take care of this?

Thanks,
Felipe

> 
> Paolo

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-30 14:21         ` Felipe Franciosi
@ 2017-05-30 14:29           ` Paolo Bonzini
  2017-05-30 14:34             ` Felipe Franciosi
  0 siblings, 1 reply; 30+ messages in thread
From: Paolo Bonzini @ 2017-05-30 14:29 UTC (permalink / raw)
  To: Felipe Franciosi; +Cc: Stefan Hajnoczi, qemu-devel

On 30/05/2017 16:21, Felipe Franciosi wrote:
>> default-configs/pci.mak:CONFIG_VHOST_USER_SCSI=$(CONFIG_POSIX)
>> default-configs/s390x-softmmu.mak:CONFIG_VHOST_USER_SCSI=y
>>
>> Unfortunately, the mingw docker test doesn't build all targets, so I
>> missed it.
>>
>> I would like vhost-user to be available on non-Linux POSIX, but this is
>> not immediately possible because vhost-backend.c includes the kernel
>> backend.  So we'll have to change CONFIG_POSIX to CONFIG_LINUX too.
> Sounds good to me. Do you need anything from my end or are you happy to take care of this?

If you'd like to take a look at breaking vhost-backend.c, that would be
nice.

Thanks,

Paolo

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

* Re: [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction
  2017-05-30 14:29           ` Paolo Bonzini
@ 2017-05-30 14:34             ` Felipe Franciosi
  0 siblings, 0 replies; 30+ messages in thread
From: Felipe Franciosi @ 2017-05-30 14:34 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Stefan Hajnoczi, qemu-devel


> On 30 May 2017, at 15:29, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> On 30/05/2017 16:21, Felipe Franciosi wrote:
>>> default-configs/pci.mak:CONFIG_VHOST_USER_SCSI=$(CONFIG_POSIX)
>>> default-configs/s390x-softmmu.mak:CONFIG_VHOST_USER_SCSI=y
>>> 
>>> Unfortunately, the mingw docker test doesn't build all targets, so I
>>> missed it.
>>> 
>>> I would like vhost-user to be available on non-Linux POSIX, but this is
>>> not immediately possible because vhost-backend.c includes the kernel
>>> backend.  So we'll have to change CONFIG_POSIX to CONFIG_LINUX too.
>> Sounds good to me. Do you need anything from my end or are you happy to take care of this?
> 
> If you'd like to take a look at breaking vhost-backend.c, that would be
> nice.


Sure. I'll add that to my list and have a stab at it later on^W^W eventually.

But I meant wrt mingw?

Felipe

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

end of thread, other threads:[~2017-05-30 14:34 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-05 10:13 [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 01/21] hw/i386: Use Rev3 FADT (ACPI 2.0) instead of Rev1 to improve guest OS support Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 02/21] hw/i386: Build-time assertion on pc/q35 reset register being identical Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 03/21] char: Fix removing wrong GSource that be found by fd_in_tag Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 04/21] target/i386: Add GDB XML register description support Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 05/21] use _Static_assert in QEMU_BUILD_BUG_ON Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 06/21] vl: deprecate the "-hdachs" option Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 07/21] scsi: avoid an off-by-one error in megasas_mmio_write Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 08/21] sgabios: update for "fix wrong video attrs for int 10h, ah==13h" Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 09/21] vmw_pvscsi: check message ring page count at initialisation Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 10/21] trace: add qemu mutex lock and unlock trace events Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 11/21] checkpatch: Disallow glib asserts in main code Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 12/21] hax: Fix memory mapping de-duplication logic Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 13/21] dump: Acquire BQL around vm_start() in dump thread Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 14/21] Fix the -accel parameter and the documentation for 'hax' Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 15/21] MAINTAINERS: Add "R:" tag for self-appointed reviewers Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 16/21] get_maintainer: Teach get_maintainer.pl about the new "R:" tag Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 17/21] get_maintainer: it's '--pattern-depth', not '-pattern-depth' Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 18/21] get_maintainer: --r (list reviewer) is on by default Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 19/21] get_maintainer: add subsystem to reviewer output Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 20/21] libvhost-user: replace vasprintf() to fix build Paolo Bonzini
2017-05-05 10:13 ` [Qemu-devel] [PULL 21/21] vhost-scsi: create a vhost-scsi-common abstraction Paolo Bonzini
2017-05-30 13:11   ` Stefan Hajnoczi
2017-05-30 14:06     ` Felipe Franciosi
2017-05-30 14:16       ` Paolo Bonzini
2017-05-30 14:21         ` Felipe Franciosi
2017-05-30 14:29           ` Paolo Bonzini
2017-05-30 14:34             ` Felipe Franciosi
2017-05-08 17:02 ` [Qemu-devel] [PULL 00/21] Misc patches for 2017-05-05 Stefan Hajnoczi
2017-05-30 13:13 ` Stefan Hajnoczi

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.