qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes
@ 2014-09-30  9:39 Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify Michael S. Tsirkin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:39 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori

The following changes since commit ed9114356b587b362f5ed10e75366a4f07ed32af:

  raw-posix: Fix build without posix_fallocate() (2014-09-29 16:28:24 +0100)

are available in the git repository at:

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

for you to fetch changes up to 28d16f38d0d5881f95b074cc802dae8cacc1bf58:

  vl: Adjust the place of calling mlockall to speedup VM's startup (2014-09-29 19:44:04 +0300)

----------------------------------------------------------------
pci, pc, virtio, misc bugfixes

A bunch of bugfixes.

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

----------------------------------------------------------------
Gonglei (1):
      pci-hotplug-old: avoid losing error message

Markus Armbruster (1):
      loader: g_realloc(p, 0) frees and returns NULL, simplify

Michael S. Tsirkin (1):
      Revert "virtio-pci: fix migration for pci bus master"

zhanghailiang (2):
      pc-dimm: Don't check dimm->node when there is non-NUMA config
      vl: Adjust the place of calling mlockall to speedup VM's startup

 include/hw/elf_ops.h     | 15 +++++----------
 hw/mem/pc-dimm.c         |  2 +-
 hw/pci/pci-hotplug-old.c |  5 ++++-
 hw/virtio/virtio-pci.c   | 39 +++++++++++++++++++--------------------
 vl.c                     | 11 +++++------
 5 files changed, 34 insertions(+), 38 deletions(-)

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

* [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
@ 2014-09-30  9:40 ` Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 2/5] Revert "virtio-pci: fix migration for pci bus master" Michael S. Tsirkin
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Alexey Kardashevskiy, Peter Maydell, Markus Armbruster,
	Anthony Liguori, Alexander Graf

From: Markus Armbruster <armbru@redhat.com>

Once upon a time, it was decided that qemu_realloc(ptr, 0) should
abort.  Switching to glib retired that bright idea.  A bit of code
that was added to cope with it (commit 3e372cf) is still around.  Bury
it.

See also commit 6528499.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/elf_ops.h | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/hw/elf_ops.h b/include/hw/elf_ops.h
index c6b5129..a517753 100644
--- a/include/hw/elf_ops.h
+++ b/include/hw/elf_ops.h
@@ -147,18 +147,13 @@ static int glue(load_symbols, SZ)(struct elfhdr *ehdr, int fd, int must_swab,
         }
         i++;
     }
-    if (nsyms) {
-        syms = g_realloc(syms, nsyms * sizeof(*syms));
+    syms = g_realloc(syms, nsyms * sizeof(*syms));
 
-        qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
-        for (i = 0; i < nsyms - 1; i++) {
-            if (syms[i].st_size == 0) {
-                syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
-            }
+    qsort(syms, nsyms, sizeof(*syms), glue(symcmp, SZ));
+    for (i = 0; i < nsyms - 1; i++) {
+        if (syms[i].st_size == 0) {
+            syms[i].st_size = syms[i + 1].st_value - syms[i].st_value;
         }
-    } else {
-        g_free(syms);
-        syms = NULL;
     }
 
     /* String table */
-- 
MST

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

* [Qemu-devel] [PULL 2/5] Revert "virtio-pci: fix migration for pci bus master"
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify Michael S. Tsirkin
@ 2014-09-30  9:40 ` Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 3/5] pci-hotplug-old: avoid losing error message Michael S. Tsirkin
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori

This reverts commit 4d43d3f3c8147ade184df9a1e9e82826edd39e19.

Reported to break PPC guests.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-pci.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index f560814..a827cd4 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -86,6 +86,9 @@
  * 12 is historical, and due to x86 page size. */
 #define VIRTIO_PCI_QUEUE_ADDR_SHIFT    12
 
+/* Flags track per-device state like workarounds for quirks in older guests. */
+#define VIRTIO_PCI_FLAG_BUS_MASTER_BUG  (1 << 0)
+
 static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
                                VirtIOPCIProxy *dev);
 
@@ -320,6 +323,14 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
                                      proxy->pci_dev.config[PCI_COMMAND] |
                                      PCI_COMMAND_MASTER, 1);
         }
+
+        /* Linux before 2.6.34 sets the device as OK without enabling
+           the PCI device bus master bit. In this case we need to disable
+           some safety checks. */
+        if ((val & VIRTIO_CONFIG_S_DRIVER_OK) &&
+            !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
+            proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
+        }
         break;
     case VIRTIO_MSI_CONFIG_VECTOR:
         msix_vector_unuse(&proxy->pci_dev, vdev->config_vector);
@@ -469,18 +480,13 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
-    uint8_t cmd = proxy->pci_dev.config[PCI_COMMAND];
-
     pci_default_write_config(pci_dev, address, val, len);
 
     if (range_covers_byte(address, len, PCI_COMMAND) &&
         !(pci_dev->config[PCI_COMMAND] & PCI_COMMAND_MASTER) &&
-        (cmd & PCI_COMMAND_MASTER)) {
-        /* Bus driver disables bus mastering - make it act
-         * as a kind of reset to render the device quiescent. */
+        !(proxy->flags & VIRTIO_PCI_FLAG_BUS_MASTER_BUG)) {
         virtio_pci_stop_ioeventfd(proxy);
-        virtio_reset(vdev);
-        msix_unuse_all_vectors(&proxy->pci_dev);
+        virtio_set_status(vdev, vdev->status & ~VIRTIO_CONFIG_S_DRIVER_OK);
     }
 }
 
@@ -889,19 +895,11 @@ static void virtio_pci_vmstate_change(DeviceState *d, bool running)
     VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus);
 
     if (running) {
-        /* Linux before 2.6.34 drives the device without enabling
-           the PCI device bus master bit. Enable it automatically
-           for the guest. This is a PCI spec violation but so is
-           initiating DMA with bus master bit clear.
-           Note: this only makes a difference when migrating
-           across QEMU versions from an old QEMU, as for new QEMU
-           bus master and driver bits are always in sync.
-           TODO: consider enabling conditionally for compat machine types. */
-        if (vdev->status & (VIRTIO_CONFIG_S_ACKNOWLEDGE |
-                            VIRTIO_CONFIG_S_DRIVER)) {
-            pci_default_write_config(&proxy->pci_dev, PCI_COMMAND,
-                                     proxy->pci_dev.config[PCI_COMMAND] |
-                                     PCI_COMMAND_MASTER, 1);
+        /* Try to find out if the guest has bus master disabled, but is
+           in ready state. Then we have a buggy guest OS. */
+        if ((vdev->status & VIRTIO_CONFIG_S_DRIVER_OK) &&
+            !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {
+            proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
         }
         virtio_pci_start_ioeventfd(proxy);
     } else {
@@ -1042,6 +1040,7 @@ static void virtio_pci_reset(DeviceState *qdev)
     virtio_pci_stop_ioeventfd(proxy);
     virtio_bus_reset(bus);
     msix_unuse_all_vectors(&proxy->pci_dev);
+    proxy->flags &= ~VIRTIO_PCI_FLAG_BUS_MASTER_BUG;
 }
 
 static Property virtio_pci_properties[] = {
-- 
MST

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

* [Qemu-devel] [PULL 3/5] pci-hotplug-old: avoid losing error message
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 2/5] Revert "virtio-pci: fix migration for pci bus master" Michael S. Tsirkin
@ 2014-09-30  9:40 ` Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 4/5] pc-dimm: Don't check dimm->node when there is non-NUMA config Michael S. Tsirkin
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Gonglei, Markus Armbruster, Anthony Liguori

From: Gonglei <arei.gonglei@huawei.com>

When scsi_bus_legacy_add_drive() produces an error,
we will lose the error message. Using error_report
to report it.

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/pci/pci-hotplug-old.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/hw/pci/pci-hotplug-old.c b/hw/pci/pci-hotplug-old.c
index cf2caeb..d87c469 100644
--- a/hw/pci/pci-hotplug-old.c
+++ b/hw/pci/pci-hotplug-old.c
@@ -107,6 +107,7 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
 {
     SCSIBus *scsibus;
     SCSIDevice *scsidev;
+    Error *local_err = NULL;
 
     scsibus = (SCSIBus *)
         object_dynamic_cast(OBJECT(QLIST_FIRST(&adapter->child_bus)),
@@ -127,8 +128,10 @@ static int scsi_hot_add(Monitor *mon, DeviceState *adapter,
     dinfo->unit = qemu_opt_get_number(dinfo->opts, "unit", -1);
     dinfo->bus = scsibus->busnr;
     scsidev = scsi_bus_legacy_add_drive(scsibus, dinfo->bdrv, dinfo->unit,
-                                        false, -1, NULL, NULL);
+                                        false, -1, NULL, &local_err);
     if (!scsidev) {
+        error_report("%s", error_get_pretty(local_err));
+        error_free(local_err);
         return -1;
     }
     dinfo->unit = scsidev->id;
-- 
MST

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

* [Qemu-devel] [PULL 4/5] pc-dimm: Don't check dimm->node when there is non-NUMA config
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2014-09-30  9:40 ` [Qemu-devel] [PULL 3/5] pci-hotplug-old: avoid losing error message Michael S. Tsirkin
@ 2014-09-30  9:40 ` Michael S. Tsirkin
  2014-09-30  9:40 ` [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup Michael S. Tsirkin
  2014-09-30 13:59 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:40 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Peter Crosthwaite, zhanghailiang, Hu Tao,
	Anthony Liguori, Igor Mammedov

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

It should not break memory hotplug feature if there is non-NUMA option.

This patch would also allow to use pc-dimm as replacement for initial memory
for non-NUMA configs.

Note: After this patch, the memory hotplug can work normally for Linux guest OS
when there is non-NUMA option and NUMA option. But not support Windows guest OS
to hotplug memory with no-NUMA config, actully, it's Windows limitation.

Reviewed-By: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/mem/pc-dimm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
index 5bfc5b7..a800ea7 100644
--- a/hw/mem/pc-dimm.c
+++ b/hw/mem/pc-dimm.c
@@ -252,7 +252,7 @@ static void pc_dimm_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "'" PC_DIMM_MEMDEV_PROP "' property is not set");
         return;
     }
-    if (dimm->node >= nb_numa_nodes) {
+    if ((nb_numa_nodes > 0) && (dimm->node >= nb_numa_nodes)) {
         error_setg(errp, "'DIMM property " PC_DIMM_NODE_PROP " has value %"
                    PRIu32 "' which exceeds the number of numa nodes: %d",
                    dimm->node, nb_numa_nodes);
-- 
MST

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

* [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2014-09-30  9:40 ` [Qemu-devel] [PULL 4/5] pc-dimm: Don't check dimm->node when there is non-NUMA config Michael S. Tsirkin
@ 2014-09-30  9:40 ` Michael S. Tsirkin
  2014-09-30 13:59 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30  9:40 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, zhanghailiang, Anthony Liguori

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

If we configure mlock=on and memory policy=bind at the same time,
It will consume lots of time for system to treat with memory,
especially when call mbind behind mlockall.

Adjust the place of calling mlockall, calling mbind before mlockall
can remarkably reduce the time of VM's startup.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 vl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/vl.c b/vl.c
index dbdca59..9d2aaaf 100644
--- a/vl.c
+++ b/vl.c
@@ -134,6 +134,7 @@ const char* keyboard_layout = NULL;
 ram_addr_t ram_size;
 const char *mem_path = NULL;
 int mem_prealloc = 0; /* force preallocation of physical target memory */
+bool enable_mlock = false;
 int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int autostart;
@@ -1421,12 +1422,8 @@ static void smp_parse(QemuOpts *opts)
 
 }
 
-static void configure_realtime(QemuOpts *opts)
+static void realtime_init(void)
 {
-    bool enable_mlock;
-
-    enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
-
     if (enable_mlock) {
         if (os_mlock() < 0) {
             fprintf(stderr, "qemu: locking memory failed\n");
@@ -3974,7 +3971,7 @@ int main(int argc, char **argv, char **envp)
                 if (!opts) {
                     exit(1);
                 }
-                configure_realtime(opts);
+                enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
                 break;
             case QEMU_OPTION_msg:
                 opts = qemu_opts_parse(qemu_find_opts("msg"), optarg, 0);
@@ -4442,6 +4439,8 @@ int main(int argc, char **argv, char **envp)
 
     machine_class->init(current_machine);
 
+    realtime_init();
+
     audio_init();
 
     cpu_synchronize_all_post_init();
-- 
MST

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

* Re: [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes
  2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2014-09-30  9:40 ` [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup Michael S. Tsirkin
@ 2014-09-30 13:59 ` Peter Maydell
  5 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2014-09-30 13:59 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: QEMU Developers, Anthony Liguori

On 30 September 2014 10:39, Michael S. Tsirkin <mst@redhat.com> wrote:
> The following changes since commit ed9114356b587b362f5ed10e75366a4f07ed32af:
>
>   raw-posix: Fix build without posix_fallocate() (2014-09-29 16:28:24 +0100)
>
> are available in the git repository at:
>
>   git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
>
> for you to fetch changes up to 28d16f38d0d5881f95b074cc802dae8cacc1bf58:
>
>   vl: Adjust the place of calling mlockall to speedup VM's startup (2014-09-29 19:44:04 +0300)
>
> ----------------------------------------------------------------
> pci, pc, virtio, misc bugfixes
>
> A bunch of bugfixes.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2014-09-30 14:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30  9:39 [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 1/5] loader: g_realloc(p, 0) frees and returns NULL, simplify Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 2/5] Revert "virtio-pci: fix migration for pci bus master" Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 3/5] pci-hotplug-old: avoid losing error message Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 4/5] pc-dimm: Don't check dimm->node when there is non-NUMA config Michael S. Tsirkin
2014-09-30  9:40 ` [Qemu-devel] [PULL 5/5] vl: Adjust the place of calling mlockall to speedup VM's startup Michael S. Tsirkin
2014-09-30 13:59 ` [Qemu-devel] [PULL 0/5] pci, pc, virtio, misc bugfixes Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).