Block layer patches:

- virtio-scsi: Fix request resubmission after I/O error with iothreads
 - qcow2: Fix missing v2/v3 subformat aliases for amend
 - qcow(1): More specific error message for wrong format version
 - MAINTAINERS: update RBD block maintainer
 -----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJdI1B3AAoJEH8JsnLIjy/W04wP/itZVqZs7yAD7p3+h/WrqjIt
 ikXB14OtwREYua2cPOYsoX2jrgMirbuqdb9uyXcEzrnoabs+ZMI/0vKEwIcl6QB7
 JXnsNkA4TubcuIuJ+j4ZreO5o52ZxfohryQJ+/yNO98o1ASc8o/lbMzUOksthhX6
 IqXNmeoYrbZELWORq3s7LyWpzccBAL4k9uGBns+RiYH6fAJPr/fpRNTzkiSQe6Lo
 3LllVb4FX8/ch1Vr5+9qgo5NV5HY5hxBpWZnGvhptnIOa/NlvvJ+p0jt+IKFdeZj
 si5Lh3uTgUQ/FVCwGntPYuQkKhdH/SNrQJHp6kL46DC0qShqWUdpyXgV8ejXpy4b
 atUog0uQ5FLdsOQHPIjYQdPGxf0NUpMbHSVhkwEEyjtjuuLdEh6mK6ySGuOqHERV
 z8orecR9jszfbV9VUXBmuAmk9a5YVGhw/pmhWhX5HGcf7RA3V0amE+wAfuCwKrFc
 vj/YVxxtzUgDGNL4i0oxrnLuSIAwiiT+9uUdmLg9QMK2cCuyHr2A5l1GT1SASEsy
 /pRgg5ZFHAw5B+EN1MJIv8rhehqCD2aaUiqD/0cblrJOyF4S8nbycVtGLmeSN/vF
 76Dw74jdTEtodtj/RLuP7uL/ucVezu4jgzrXW1l2sh0vRWIQ6NTX3czE+vhJvcbh
 DKYr3pd5eJ21FG0EmJAk
 =Rc+h
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches:

- virtio-scsi: Fix request resubmission after I/O error with iothreads
- qcow2: Fix missing v2/v3 subformat aliases for amend
- qcow(1): More specific error message for wrong format version
- MAINTAINERS: update RBD block maintainer

# gpg: Signature made Mon 08 Jul 2019 15:17:27 BST
# gpg:                using RSA key 7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream:
  qcow2: Allow -o compat=v3 during qemu-img amend
  MAINTAINERS: update RBD block maintainer
  block/qcow: Improve error when opening qcow2 files as qcow
  virtio-scsi: restart DMA after iothread
  qdev: add qdev_add_vm_change_state_handler()
  vl: add qemu_add_vm_change_state_handler_prio()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2019-07-08 15:21:20 +01:00
commit a4efdb6b24
10 changed files with 133 additions and 24 deletions

View File

@ -2385,7 +2385,7 @@ S: Supported
F: block/vmdk.c
RBD
M: Josh Durgin <jdurgin@redhat.com>
M: Jason Dillaman <dillaman@redhat.com>
L: qemu-block@nongnu.org
S: Supported
F: block/rbd.c

View File

@ -156,7 +156,12 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
if (header.version != QCOW_VERSION) {
error_setg(errp, "Unsupported qcow version %" PRIu32, header.version);
error_setg(errp, "qcow (v%d) does not support qcow version %" PRIu32,
QCOW_VERSION, header.version);
if (header.version == 2 || header.version == 3) {
error_append_hint(errp, "Try the 'qcow2' driver instead.\n");
}
ret = -ENOTSUP;
goto fail;
}

View File

@ -4823,9 +4823,9 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
compat = qemu_opt_get(opts, BLOCK_OPT_COMPAT_LEVEL);
if (!compat) {
/* preserve default */
} else if (!strcmp(compat, "0.10")) {
} else if (!strcmp(compat, "0.10") || !strcmp(compat, "v2")) {
new_version = 2;
} else if (!strcmp(compat, "1.1")) {
} else if (!strcmp(compat, "1.1") || !strcmp(compat, "v3")) {
new_version = 3;
} else {
error_setg(errp, "Unknown compatibility level %s", compat);
@ -5098,7 +5098,7 @@ static QemuOptsList qcow2_create_opts = {
{
.name = BLOCK_OPT_COMPAT_LEVEL,
.type = QEMU_OPT_STRING,
.help = "Compatibility level (0.10 or 1.1)"
.help = "Compatibility level (v2 [0.10] or v3 [1.1])"
},
{
.name = BLOCK_OPT_BACKING_FILE,

View File

@ -7,6 +7,7 @@ common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
common-obj-y += irq.o
common-obj-y += hotplug.o
common-obj-$(CONFIG_SOFTMMU) += nmi.o
common-obj-$(CONFIG_SOFTMMU) += vm-change-state-handler.o
common-obj-$(CONFIG_EMPTY_SLOT) += empty_slot.o
common-obj-$(CONFIG_XILINX_AXI) += stream.o

View File

@ -0,0 +1,61 @@
/*
* qdev vm change state handlers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "qemu/osdep.h"
#include "hw/qdev.h"
static int qdev_get_dev_tree_depth(DeviceState *dev)
{
int depth;
for (depth = 0; dev; depth++) {
BusState *bus = dev->parent_bus;
if (!bus) {
break;
}
dev = bus->parent;
}
return depth;
}
/**
* qdev_add_vm_change_state_handler:
* @dev: the device that owns this handler
* @cb: the callback function to be invoked
* @opaque: user data passed to the callback function
*
* This function works like qemu_add_vm_change_state_handler() except callbacks
* are invoked in qdev tree depth order. Ordering is desirable when callbacks
* of children depend on their parent's callback having completed first.
*
* For example, when qdev_add_vm_change_state_handler() is used, a host
* controller's callback is invoked before the children on its bus when the VM
* starts running. The order is reversed when the VM stops running.
*
* Returns: an entry to be freed with qemu_del_vm_change_state_handler()
*/
VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
VMChangeStateHandler *cb,
void *opaque)
{
int depth = qdev_get_dev_tree_depth(dev);
return qemu_add_vm_change_state_handler_prio(cb, opaque, depth);
}

View File

@ -207,8 +207,8 @@ static void scsi_qdev_realize(DeviceState *qdev, Error **errp)
error_propagate(errp, local_err);
return;
}
dev->vmsentry = qemu_add_vm_change_state_handler(scsi_dma_restart_cb,
dev);
dev->vmsentry = qdev_add_vm_change_state_handler(DEVICE(dev),
scsi_dma_restart_cb, dev);
}
static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp)

View File

@ -2362,8 +2362,8 @@ void virtio_init(VirtIODevice *vdev, const char *name,
} else {
vdev->config = NULL;
}
vdev->vmstate = qemu_add_vm_change_state_handler(virtio_vmstate_change,
vdev);
vdev->vmstate = qdev_add_vm_change_state_handler(DEVICE(vdev),
virtio_vmstate_change, vdev);
vdev->device_endian = virtio_default_endian();
vdev->use_guest_notifier_mask = true;
}

View File

@ -6,6 +6,7 @@
#include "qom/object.h"
#include "hw/irq.h"
#include "hw/hotplug.h"
#include "sysemu/sysemu.h"
enum {
DEV_NVECTORS_UNSPECIFIED = -1,
@ -450,4 +451,8 @@ static inline bool qbus_is_hotpluggable(BusState *bus)
void device_listener_register(DeviceListener *listener);
void device_listener_unregister(DeviceListener *listener);
VMChangeStateEntry *qdev_add_vm_change_state_handler(DeviceState *dev,
VMChangeStateHandler *cb,
void *opaque);
#endif

View File

@ -29,6 +29,8 @@ typedef void VMChangeStateHandler(void *opaque, int running, RunState state);
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void *opaque);
VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
VMChangeStateHandler *cb, void *opaque, int priority);
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e);
void vm_state_notify(int running, RunState state);

61
vl.c
View File

@ -1365,27 +1365,56 @@ static int machine_help_func(QemuOpts *opts, MachineState *machine)
struct vm_change_state_entry {
VMChangeStateHandler *cb;
void *opaque;
QLIST_ENTRY (vm_change_state_entry) entries;
QTAILQ_ENTRY(vm_change_state_entry) entries;
int priority;
};
static QLIST_HEAD(, vm_change_state_entry) vm_change_state_head;
static QTAILQ_HEAD(, vm_change_state_entry) vm_change_state_head;
/**
* qemu_add_vm_change_state_handler_prio:
* @cb: the callback to invoke
* @opaque: user data passed to the callback
* @priority: low priorities execute first when the vm runs and the reverse is
* true when the vm stops
*
* Register a callback function that is invoked when the vm starts or stops
* running.
*
* Returns: an entry to be freed using qemu_del_vm_change_state_handler()
*/
VMChangeStateEntry *qemu_add_vm_change_state_handler_prio(
VMChangeStateHandler *cb, void *opaque, int priority)
{
VMChangeStateEntry *e;
VMChangeStateEntry *other;
e = g_malloc0(sizeof(*e));
e->cb = cb;
e->opaque = opaque;
e->priority = priority;
/* Keep list sorted in ascending priority order */
QTAILQ_FOREACH(other, &vm_change_state_head, entries) {
if (priority < other->priority) {
QTAILQ_INSERT_BEFORE(other, e, entries);
return e;
}
}
QTAILQ_INSERT_TAIL(&vm_change_state_head, e, entries);
return e;
}
VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
void *opaque)
{
VMChangeStateEntry *e;
e = g_malloc0(sizeof (*e));
e->cb = cb;
e->opaque = opaque;
QLIST_INSERT_HEAD(&vm_change_state_head, e, entries);
return e;
return qemu_add_vm_change_state_handler_prio(cb, opaque, 0);
}
void qemu_del_vm_change_state_handler(VMChangeStateEntry *e)
{
QLIST_REMOVE (e, entries);
QTAILQ_REMOVE(&vm_change_state_head, e, entries);
g_free(e);
}
@ -1395,9 +1424,15 @@ void vm_state_notify(int running, RunState state)
trace_vm_state_notify(running, state, RunState_str(state));
QLIST_FOREACH_SAFE(e, &vm_change_state_head, entries, next) {
if (running) {
QTAILQ_FOREACH_SAFE(e, &vm_change_state_head, entries, next) {
e->cb(e->opaque, running, state);
}
} else {
QTAILQ_FOREACH_REVERSE_SAFE(e, &vm_change_state_head, entries, next) {
e->cb(e->opaque, running, state);
}
}
}
static ShutdownCause reset_requested;
@ -2911,7 +2946,7 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
QLIST_INIT (&vm_change_state_head);
QTAILQ_INIT(&vm_change_state_head);
os_setup_early_signal_handling();
cpu_option = NULL;