Backport fixes from master to stable-0.13
cover Backport fixes from master to stable-0.13
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(-)
Signature · 1 line
1.7.2.2
PATCH 1/4 virtio-serial: Check if more max_ports specified than we can handle
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.
--- hw/virtio-serial-bus.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
hw/virtio-serial-bus.c +9 -1
@@ -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));
Signature · 1 line
1.7.2.2
PATCH 2/4 migration: Accept 'cont' only after successful incoming migration
In reply to Amit ShahWhen 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.
--- 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(-)
migration.c +2 -0
@@ -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 (); }
monitor.c +4 -0
@@ -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) {
qerror.c +4 -0
@@ -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", },
qerror.h +3 -0
@@ -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 } }"
sysemu.h +1 -0
@@ -99,6 +99,7 @@ typedef enum DisplayType } DisplayType;extern int autostart; +extern int incoming_expected;extern int bios_size; typedef enum {
vl.c +2 -0
@@ -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 ;
Signature · 1 line
1.7.2.2
PATCH 3/4 rtc: Remove TARGET_I386 from qemu-config.c, enables driftfix
In reply to Amit Shahqemu-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.
--- qemu-config.c | 2 -- 1 files changed, 0 insertions(+), 2 deletions(-)
qemu-config.c +0 -2
@@ -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 */ } },
Signature · 1 line
1.7.2.2
PATCH 4/4 virtio-serial: Cleanup on device hot-unplug
In reply to Amit ShahFree 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.
--- hw/virtio-pci.c | 10 +++++++++- hw/virtio-serial-bus.c | 17 +++++++++++++++++ hw/virtio.h | 1 + 3 files changed, 27 insertions(+), 1 deletions(-)
hw/virtio-pci.c +9 -1
@@ -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 ),
hw/virtio-serial-bus.c +17 -0
@@ -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); +}
hw/virtio.h +1 -0
@@ -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, \
Signature · 1 line
1.7.2.2