qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13
@ 2010-09-08 10:52 Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 1/4] virtio-serial: Check if more max_ports specified than we can handle Amit Shah
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Amit Shah @ 2010-09-08 10:52 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu list

Hello,

These are a few fixes which I've submitted that are included in master
but not in stable-0.13.

Patches 1 and 4 fix virtio-serial crash and migration, patch 2 fixes a
non-starting guest after migration in a particular case and patch 3
fixes the driftfix parameter needed by some guests.

The commit ids from which they're backported are mentioned in the
individual patches.

Please apply.

Amit Shah (4):
  virtio-serial: Check if more max_ports specified than we can handle
  migration: Accept 'cont' only after successful incoming migration
  rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix
  virtio-serial: Cleanup on device hot-unplug

 hw/virtio-pci.c        |   10 +++++++++-
 hw/virtio-serial-bus.c |   27 ++++++++++++++++++++++++++-
 hw/virtio.h            |    1 +
 migration.c            |    2 ++
 monitor.c              |    4 ++++
 qemu-config.c          |    2 --
 qerror.c               |    4 ++++
 qerror.h               |    3 +++
 sysemu.h               |    1 +
 vl.c                   |    2 ++
 10 files changed, 52 insertions(+), 4 deletions(-)

-- 
1.7.2.2

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

* [Qemu-devel] [PATCH 1/4] virtio-serial: Check if more max_ports specified than we can handle
  2010-09-08 10:52 [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13 Amit Shah
@ 2010-09-08 10:52 ` Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 2/4] migration: Accept 'cont' only after successful incoming migration Amit Shah
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2010-09-08 10:52 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu list, Aurelien Jarno

Currently virtio-serial supports a maximum of 31 ports. Specifying the
'max_ports' parameter to be > 31 on the cmd line causes badness.

Ensure we initialise virtio-serial only if max_ports is within the
supported range.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 5ab4bb598d3f58542a06a6946f04b140be222892)

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-serial-bus.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 8e611c0..0586b89 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -734,11 +734,19 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
 {
     VirtIOSerial *vser;
     VirtIODevice *vdev;
-    uint32_t i;
+    uint32_t i, max_supported_ports;
 
     if (!max_nr_ports)
         return NULL;
 
+    /* Each port takes 2 queues, and one pair is for the control queue */
+    max_supported_ports = VIRTIO_PCI_QUEUE_MAX / 2 - 1;
+
+    if (max_nr_ports > max_supported_ports) {
+        error_report("maximum ports supported: %u", max_supported_ports);
+        return NULL;
+    }
+
     vdev = virtio_common_init("virtio-serial", VIRTIO_ID_CONSOLE,
                               sizeof(struct virtio_console_config),
                               sizeof(VirtIOSerial));
-- 
1.7.2.2

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

* [Qemu-devel] [PATCH 2/4] migration: Accept 'cont' only after successful incoming migration
  2010-09-08 10:52 [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13 Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 1/4] virtio-serial: Check if more max_ports specified than we can handle Amit Shah
@ 2010-09-08 10:52 ` Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 3/4] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix Amit Shah
  2010-09-08 10:53 ` [Qemu-devel] [PATCH 4/4] virtio-serial: Cleanup on device hot-unplug Amit Shah
  3 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2010-09-08 10:52 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu list, Aurelien Jarno

When a 'cont' is issued on a VM that's just waiting for an incoming
migration, the VM reboots and boots into the guest, possibly corrupting
its storage since it could be shared with another VM running elsewhere.

Ensure that a VM started with '-incoming' is only run when an incoming
migration successfully completes.

A new qerror, QERR_MIGRATION_EXPECTED, is added to signal that 'cont'
failed due to no incoming migration has been attempted yet.

Reported-by: Laine Stump <laine@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 8e84865e54cb66fd7b57bb18c312ad3d56b6e276)

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 migration.c |    2 ++
 monitor.c   |    4 ++++
 qerror.c    |    4 ++++
 qerror.h    |    3 +++
 sysemu.h    |    1 +
 vl.c        |    2 ++
 6 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/migration.c b/migration.c
index 650eb78..a160462 100644
--- a/migration.c
+++ b/migration.c
@@ -67,6 +67,8 @@ void process_incoming_migration(QEMUFile *f)
     qemu_announce_self();
     DPRINTF("successfully loaded vm state\n");
 
+    incoming_expected = false;
+
     if (autostart)
         vm_start();
 }
diff --git a/monitor.c b/monitor.c
index 45fd482..5366c36 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1056,6 +1056,10 @@ static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data)
 {
     struct bdrv_iterate_context context = { mon, 0 };
 
+    if (incoming_expected) {
+        qerror_report(QERR_MIGRATION_EXPECTED);
+        return -1;
+    }
     bdrv_iterate(encrypted_bdrv_it, &context);
     /* only resume the vm if all keys are set and valid */
     if (!context.err) {
diff --git a/qerror.c b/qerror.c
index 2f6f590..0af3ab3 100644
--- a/qerror.c
+++ b/qerror.c
@@ -141,6 +141,10 @@ static const QErrorStringTable qerror_table[] = {
         .desc      = "Using KVM without %(capability), %(feature) unavailable",
     },
     {
+        .error_fmt = QERR_MIGRATION_EXPECTED,
+        .desc      = "An incoming migration is expected before this command can be executed",
+    },
+    {
         .error_fmt = QERR_MISSING_PARAMETER,
         .desc      = "Parameter '%(name)' is missing",
     },
diff --git a/qerror.h b/qerror.h
index 9ad00b4..62802ea 100644
--- a/qerror.h
+++ b/qerror.h
@@ -121,6 +121,9 @@ QError *qobject_to_qerror(const QObject *obj);
 #define QERR_KVM_MISSING_CAP \
     "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }"
 
+#define QERR_MIGRATION_EXPECTED \
+    "{ 'class': 'MigrationExpected', 'data': {} }"
+
 #define QERR_MISSING_PARAMETER \
     "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
 
diff --git a/sysemu.h b/sysemu.h
index 9c988bb..a1f6466 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -99,6 +99,7 @@ typedef enum DisplayType
 } DisplayType;
 
 extern int autostart;
+extern int incoming_expected;
 extern int bios_size;
 
 typedef enum {
diff --git a/vl.c b/vl.c
index ba6ee11..c2e7cc1 100644
--- a/vl.c
+++ b/vl.c
@@ -182,6 +182,7 @@ int nb_nics;
 NICInfo nd_table[MAX_NICS];
 int vm_running;
 int autostart;
+int incoming_expected; /* Started with -incoming and waiting for incoming */
 static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 QEMUClock *rtc_clock;
@@ -2557,6 +2558,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_incoming:
                 incoming = optarg;
+                incoming_expected = true;
                 break;
             case QEMU_OPTION_nodefaults:
                 default_serial = 0;
-- 
1.7.2.2

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

* [Qemu-devel] [PATCH 3/4] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix
  2010-09-08 10:52 [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13 Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 1/4] virtio-serial: Check if more max_ports specified than we can handle Amit Shah
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 2/4] migration: Accept 'cont' only after successful incoming migration Amit Shah
@ 2010-09-08 10:52 ` Amit Shah
  2010-09-08 10:53 ` [Qemu-devel] [PATCH 4/4] virtio-serial: Cleanup on device hot-unplug Amit Shah
  3 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2010-09-08 10:52 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, Anthony Liguori, qemu list

qemu-config.c doesn't contain any target-specific code, and the
TARGET_I386 conditional code didn't get compiled as a result. Removing
this enables the driftfix parameter for rtc.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 027c9e21e21bbe63f74ffb86381bb11315a1544c)

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-config.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/qemu-config.c b/qemu-config.c
index 95abe61..730ffd9 100644
--- a/qemu-config.c
+++ b/qemu-config.c
@@ -247,11 +247,9 @@ QemuOptsList qemu_rtc_opts = {
         },{
             .name = "clock",
             .type = QEMU_OPT_STRING,
-#ifdef TARGET_I386
         },{
             .name = "driftfix",
             .type = QEMU_OPT_STRING,
-#endif
         },
         { /* end if list */ }
     },
-- 
1.7.2.2

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

* [Qemu-devel] [PATCH 4/4] virtio-serial: Cleanup on device hot-unplug
  2010-09-08 10:52 [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13 Amit Shah
                   ` (2 preceding siblings ...)
  2010-09-08 10:52 ` [Qemu-devel] [PATCH 3/4] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix Amit Shah
@ 2010-09-08 10:53 ` Amit Shah
  3 siblings, 0 replies; 5+ messages in thread
From: Amit Shah @ 2010-09-08 10:53 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, Anthony Liguori, qemu list

Free malloc'ed memory, unregister from savevm and clean up virtio-common
bits on device hot-unplug.

This was found performing a migration after device hot-unplug.

Reported-by: <lihuang@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
(cherry picked from commit 8b53a865772789a3402a44aa80169f8dd728eba2)

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 hw/virtio-pci.c        |   10 +++++++++-
 hw/virtio-serial-bus.c |   17 +++++++++++++++++
 hw/virtio.h            |    1 +
 3 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 17c3d15..82a6d78 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -599,6 +599,14 @@ static int virtio_serial_init_pci(PCIDevice *pci_dev)
     return 0;
 }
 
+static int virtio_serial_exit_pci(PCIDevice *pci_dev)
+{
+    VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+
+    virtio_serial_exit(proxy->vdev);
+    return virtio_exit_pci(pci_dev);
+}
+
 static int virtio_net_init_pci(PCIDevice *pci_dev)
 {
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
@@ -689,7 +697,7 @@ static PCIDeviceInfo virtio_info[] = {
         .qdev.alias = "virtio-serial",
         .qdev.size = sizeof(VirtIOPCIProxy),
         .init      = virtio_serial_init_pci,
-        .exit      = virtio_exit_pci,
+        .exit      = virtio_serial_exit_pci,
         .qdev.props = (Property[]) {
             DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
                                DEV_NVECTORS_UNSPECIFIED),
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 0586b89..74ba5ec 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -41,6 +41,8 @@ struct VirtIOSerial {
 
     VirtIOSerialBus *bus;
 
+    DeviceState *qdev;
+
     QTAILQ_HEAD(, VirtIOSerialPort) ports;
 
     /* bitmap for identifying active ports */
@@ -792,6 +794,8 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
     vser->vdev.get_config = get_config;
     vser->vdev.set_config = set_config;
 
+    vser->qdev = dev;
+
     /*
      * Register for the savevm section with the virtio-console name
      * to preserve backward compat
@@ -801,3 +805,16 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, uint32_t max_nr_ports)
 
     return vdev;
 }
+
+void virtio_serial_exit(VirtIODevice *vdev)
+{
+    VirtIOSerial *vser = DO_UPCAST(VirtIOSerial, vdev, vdev);
+
+    unregister_savevm(vser->qdev, "virtio-console", vser);
+
+    qemu_free(vser->ivqs);
+    qemu_free(vser->ovqs);
+    qemu_free(vser->ports_map);
+
+    virtio_cleanup(vdev);
+}
diff --git a/hw/virtio.h b/hw/virtio.h
index 764970c..1deeb2c 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -198,6 +198,7 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf);
 
 void virtio_net_exit(VirtIODevice *vdev);
 void virtio_blk_exit(VirtIODevice *vdev);
+void virtio_serial_exit(VirtIODevice *vdev);
 
 #define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
 	DEFINE_PROP_BIT("indirect_desc", _state, _field, \
-- 
1.7.2.2

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

end of thread, other threads:[~2010-09-08 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-08 10:52 [Qemu-devel] [PATCH 0/4] Backport fixes from master to stable-0.13 Amit Shah
2010-09-08 10:52 ` [Qemu-devel] [PATCH 1/4] virtio-serial: Check if more max_ports specified than we can handle Amit Shah
2010-09-08 10:52 ` [Qemu-devel] [PATCH 2/4] migration: Accept 'cont' only after successful incoming migration Amit Shah
2010-09-08 10:52 ` [Qemu-devel] [PATCH 3/4] rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix Amit Shah
2010-09-08 10:53 ` [Qemu-devel] [PATCH 4/4] virtio-serial: Cleanup on device hot-unplug Amit Shah

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).