Miscellaneous patches for 2017-06-06

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABAgAGBQJZNlojAAoJEDhwtADrkYZTiXEP/19oBKWuHD2RgoYbKYQrCuoJ
 WlO7FrH73rR0uEP9D1zNy7Y5DW1IliZk96FqIW4Y3kdCLIEQyw64Wqe0/1fkj7oE
 S62N5RA4ZUurCcmdgCY+/fXD1qLvSJ6cDduaCnT51xmm5lVclGq0Fl0zsZHtsJqs
 0Sp6K8yKZiIRVzaZJh9BRurU6B0lpX6r29qcKGzlZkv0QokCG6zvNRila/9bza21
 1c6cLBPOMg4YKGe03ZNE82AviD1/XxSgFtsPh3z76h3i9MR82OJTG/dDlcSmjys0
 KLM/0JtYKStzqGiOEFR6lyMIVl8suDsSWHBtj6XXRAjhen0Pw++f7nrsJV4fYHm4
 lhEKdIYWZu/SzkWr/W+u1zIYudhcKg6PbXka18X0qzMPeJakL9lP6OBAqZ8Ys+4M
 m+nV8QkDIwmDS0jKWPgI5P+zVvJUGSiJ5ln0xydHjLyCT+zTIKIzGUncbe4YoGEJ
 eAjGG28r5QtxdmJuMgHZrCzZOvOyD3Tloz79v9Esyr+OTzyNQux1yCwIQmvGYu3b
 tyrzsTwcXHdV1u+u7XRQpiRbqfQtBbK8R1lzmis1jCtlwbrpSiIc/O9VunCXW7eQ
 pFXPZAvMsr++JLgJ/jMLGMdmMpUJgM5w/tQ/+dyTvBZEQWp+NyK0gDtfu/Xq3HcG
 S/kPyjh8tbYDCMT9gwtC
 =17y9
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/armbru/tags/pull-misc-2017-06-06' into staging

Miscellaneous patches for 2017-06-06

# gpg: Signature made Tue 06 Jun 2017 08:30:43 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-misc-2017-06-06:
  monitor: fix object_del for command-line-created objects
  tests: check-qom-proplist: add checks for cmdline-created objects
  virtio-scsi-test: Use scsi-hd instead of legacy scsi-disk
  block: Clarify documentation of BlockInfo member io-status

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2017-06-06 15:37:53 +01:00
commit 572db7cd69
4 changed files with 68 additions and 2 deletions

View File

@ -449,7 +449,8 @@
#
# @io-status: @BlockDeviceIoStatus. Only present if the device
# supports it and the VM is configured to stop on errors
# (supported device models: virtio-blk, ide, scsi-disk)
# (supported device models: virtio-blk, IDE, SCSI except
# scsi-generic)
#
# @inserted: @BlockDeviceInfo describing the device if media is
# present

View File

@ -4,6 +4,7 @@
#include "qemu/module.h"
#include "qapi-visit.h"
#include "qapi/opts-visitor.h"
#include "qemu/config-file.h"
void user_creatable_complete(Object *obj, Error **errp)
{
@ -181,6 +182,14 @@ void user_creatable_del(const char *id, Error **errp)
error_setg(errp, "object '%s' is in use, can not be deleted", id);
return;
}
/*
* if object was defined on the command-line, remove its corresponding
* option group entry
*/
qemu_opts_del(qemu_opts_find(qemu_find_opts_err("object", &error_abort),
id));
object_unparent(obj);
}

View File

@ -23,6 +23,9 @@
#include "qapi/error.h"
#include "qom/object.h"
#include "qemu/module.h"
#include "qemu/option.h"
#include "qemu/config-file.h"
#include "qom/object_interfaces.h"
#define TYPE_DUMMY "qemu-dummy"
@ -162,6 +165,10 @@ static const TypeInfo dummy_info = {
.instance_finalize = dummy_finalize,
.class_size = sizeof(DummyObjectClass),
.class_init = dummy_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
}
};
@ -320,6 +327,14 @@ static const TypeInfo dummy_backend_info = {
.class_size = sizeof(DummyBackendClass),
};
static QemuOptsList qemu_object_opts = {
.name = "object",
.implied_opt_name = "qom-type",
.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
.desc = {
{ }
},
};
static void test_dummy_createv(void)
@ -388,6 +403,46 @@ static void test_dummy_createlist(void)
object_unparent(OBJECT(dobj));
}
static void test_dummy_createcmdl(void)
{
QemuOpts *opts;
DummyObject *dobj;
Error *err = NULL;
const char *params = TYPE_DUMMY \
",id=dev0," \
"bv=yes,sv=Hiss hiss hiss,av=platypus";
qemu_add_opts(&qemu_object_opts);
opts = qemu_opts_parse(&qemu_object_opts, params, true, &err);
g_assert(err == NULL);
g_assert(opts);
dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err));
g_assert(err == NULL);
g_assert(dobj);
g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
g_assert(dobj->bv == true);
g_assert(dobj->av == DUMMY_PLATYPUS);
user_creatable_del("dev0", &err);
g_assert(err == NULL);
error_free(err);
/*
* cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
* corresponding to the Object's ID to be added to the QemuOptsList
* for objects. To avoid having this entry conflict with future
* Objects using the same ID (which can happen in cases where
* qemu_opts_parse() is used to parse the object params, such as
* with hmp_object_add() at the time of this comment), we need to
* check for this in user_creatable_del() and remove the QemuOpts if
* it is present.
*
* The below check ensures this works as expected.
*/
g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0"));
}
static void test_dummy_badenum(void)
{
Error *err = NULL;
@ -525,6 +580,7 @@ int main(int argc, char **argv)
g_test_add_func("/qom/proplist/createlist", test_dummy_createlist);
g_test_add_func("/qom/proplist/createv", test_dummy_createv);
g_test_add_func("/qom/proplist/createcmdline", test_dummy_createcmdl);
g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
g_test_add_func("/qom/proplist/getenum", test_dummy_getenum);
g_test_add_func("/qom/proplist/iterator", test_dummy_iterator);

View File

@ -149,7 +149,7 @@ static QVirtIOSCSI *qvirtio_scsi_pci_init(int slot)
vs->qs = qvirtio_scsi_start("-drive file=blkdebug::null-co://,"
"if=none,id=dr1,format=raw,file.align=4k "
"-device scsi-disk,drive=dr1,lun=0,scsi-id=1");
"-device scsi-hd,drive=dr1,lun=0,scsi-id=1");
dev = qvirtio_pci_device_find(vs->qs->pcibus, VIRTIO_ID_SCSI);
vs->dev = (QVirtioDevice *)dev;
g_assert(dev != NULL);