qapi-related cleanups
Subsystems (2)
v5 cover qapi-related cleanups
This is a subset of my earlier post "Rip out dynamic JSON parsing"[1], and then a rebase of that work onto master. It is available here:
git fetch git://repo.or.cz/qemu/ericb.git qapi-dynamic-json-v5
the tag name is a bit of a misnomer for the current series, but is historically accurate.
Since v4 [2], I've addressed the minor review comments:
- drop unneeded '.' in comments [Markus]
- merge 3 patches into one, since the artifical split between patches was not nice, and since it's all automated anyway [Markus]
- rebase to master (Coccinelle found more places that could be improved)
- add R-b tags
This will probably be a conflict magnet the longer it is not applied (conversely, since it is now generated by Coccinelle, it will be a lot easier to regenerate the series if another round of rebasing is needed).
[1] https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg05425.html
[2] https://lists.gnu.org/archive/html/qemu-devel/2017-04/msg01970.html
001/10:[----] [--] 'pci: Use struct instead of QDict to pass back parameters' 002/10:[----] [--] 'pci: Reduce scope of error injection' 003/10:[----] [--] 'coccinelle: Add script to remove useless QObject casts' 004/10:[----] [--] 'qobject: Drop useless QObject casts' 005/10:[0004] [FC] 'qobject: Add helper macros for common scalar insertions' 006/10:[0380] [FC] 'qobject: Use simpler QDict/QList scalar insertion macros' 007/10:[----] [--] 'block: Simplify bdrv_append_temp_snapshot() logic' 008/10:[----] [--] 'QemuOpts: Simplify qemu_opts_to_qdict()' 009/10:[----] [--] 'fdc-test: Avoid deprecated 'change' command' 010/10:[----] [--] 'test-qga: Actually test 0xff sync bytes'
Eric Blake (10):
pci: Use struct instead of QDict to pass back parameters
pci: Reduce scope of error injection
coccinelle: Add script to remove useless QObject casts
qobject: Drop useless QObject casts
qobject: Add helper macros for common scalar insertions
qobject: Use simpler QDict/QList scalar insertion macros
block: Simplify bdrv_append_temp_snapshot() logic
QemuOpts: Simplify qemu_opts_to_qdict()
fdc-test: Avoid deprecated 'change' command
test-qga: Actually test 0xff sync bytes
include/hw/pci/pcie_aer.h | 4 - include/qapi/qmp/qdict.h | 8 ++ include/qapi/qmp/qlist.h | 8 ++ block.c | 70 +++++++----------- block/blkdebug.c | 8 +- block/blkverify.c | 11 ++- block/curl.c | 2 +- block/file-posix.c | 8 +- block/file-win32.c | 4 +- block/nbd.c | 41 +++++------ block/nfs.c | 43 +++++------ block/null.c | 2 +- block/qcow2.c | 4 +- block/quorum.c | 16 ++-- block/rbd.c | 16 ++-- block/snapshot.c | 2 +- block/ssh.c | 16 ++-- block/vvfat.c | 10 +-- block/vxhs.c | 6 +- blockdev.c | 30 ++++---- hw/block/xen_disk.c | 2 +- hw/pci/pcie_aer.c | 48 +++++++----- hw/usb/xen-usb.c | 12 +-- monitor.c | 23 +++--- qapi/qmp-event.c | 2 +- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qobject/qdict.c | 2 +- target/s390x/cpu_models.c | 4 +- tests/check-qdict.c | 142 ++++++++++++++++++------------------ tests/check-qlist.c | 4 +- tests/device-introspect-test.c | 4 +- tests/fdc-test.c | 8 +- tests/libqtest.c | 8 ++ tests/test-qemu-opts.c | 4 +- tests/test-qga.c | 34 +++++++-- tests/test-qmp-commands.c | 30 ++++---- tests/test-qmp-event.c | 30 ++++---- tests/test-qobject-output-visitor.c | 6 +- util/qemu-option.c | 6 +- MAINTAINERS | 1 + scripts/coccinelle/qobject.cocci | 35 +++++++++ 43 files changed, 385 insertions(+), 339 deletions(-) create mode 100644 scripts/coccinelle/qobject.cocci
Signature · 1 line
2.9.3
PATCH v5 1/10 pci: Use struct instead of QDict to pass back parameters
It's simpler to just use a C struct than it is to bundle things into a QDict in one function just to pull them back out in the caller. Plus, doing this gets rid of one more user of dynamic JSON through qobject_from_jsonf(), as well as a memory leak of the QDict.
While cleaning the code, fix things to report all errors (the code was previously silently ignoring a failure of pcie_aer_inject_error(), at a distance).
---
v5: add R-b
v4: no change
v3: more cleanups suggested by Markus, drop R-b
--- hw/pci/pcie_aer.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-)
hw/pci/pcie_aer.c +26 -18
@@ -44,6 +44,13 @@#define PCI_ERR_SRC_COR_OFFS 0#define PCI_ERR_SRC_UNCOR_OFFS 2 +typedef struct PCIEErrorDetails { +const char *id; +const char *root_bus; +int bus; +int devfn; +}PCIEErrorDetails ; +/* From 6.2.7 Error Listing and Rules. Table 6-2, 6-3 and 6-4 */ static uint32_t pcie_aer_uncor_default_severity (uint32_t status) {
@@ -942,8 +949,14 @@ static int pcie_aer_parse_error_string(const char *error_name,return -EINVAL ; } +/* +* Inject an error described by @qdict. +* On success, set @details to show where error was sent. +* Return negative errno if injection failed and a message was emitted. +*/ static int do_pcie_aer_inject_error (Monitor *mon, -const QDict *qdict,QObject **ret_data) +const QDict *qdict, +PCIEErrorDetails *details) {const char *id =qdict_get_str (qdict,"id" );const char *error_name;
@@ -1005,33 +1018,28 @@ static int do_pcie_aer_inject_error(Monitor *mon, err.prefix[3 ] =qdict_get_try_int (qdict,"prefix3" ,0 ); ret =pcie_aer_inject_error (dev, &err); - *ret_data =qobject_from_jsonf ("{'id': %s, " -"'root_bus': %s, 'bus': %d, 'devfn': %d, " -"'ret': %d}" , - id,pci_root_bus_path (dev), -pci_bus_num (dev->bus), dev->devfn, - ret); -assert (*ret_data); +if (ret <0 ) { +monitor_printf (mon,"failed to inject error: %s\n" , +strerror (-ret)); +return ret; + } + details->id = id; + details->root_bus =pci_root_bus_path (dev); + details->bus =pci_bus_num (dev->bus); + details->devfn = dev->devfn;return 0 ; }void hmp_pcie_aer_inject_error (Monitor *mon,const QDict *qdict) { -QObject *data; -int devfn; +PCIEErrorDetails data;if (do_pcie_aer_inject_error (mon, qdict, &data) <0 ) {return ; } - qdict =qobject_to_qdict (data); -assert (qdict); - - devfn = (int )qdict_get_int (qdict,"devfn" );monitor_printf (mon,"OK id: %s root bus: %s, bus: %x devfn: %x.%x\n" , -qdict_get_str (qdict,"id" ), -qdict_get_str (qdict,"root_bus" ), - (int )qdict_get_int (qdict,"bus" ), -PCI_SLOT (devfn),PCI_FUNC (devfn)); + data.id, data.root_bus, data.bus, +PCI_SLOT (data.devfn),PCI_FUNC (data.devfn)); }
Signature · 1 line
2.9.3
PATCH v5 2/10 pci: Reduce scope of error injection
In reply to Eric BlakeNo one outside of pcie_aer.h was using error injection; mark them static for internal use.
---
v5: add R-b
v4: no change
v3: new patch, suggested by Markus
--- include/hw/pci/pcie_aer.h | 4 ---- hw/pci/pcie_aer.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-)
include/hw/pci/pcie_aer.h +0 -4
@@ -100,8 +100,4 @@ void pcie_aer_root_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len, uint32_t root_cmd_prev); -/* error injection */ -int pcie_aer_inject_error (PCIDevice *dev,const PCIEAERErr *err); -void pcie_aer_msg (PCIDevice *dev,const PCIEAERMsg *msg); -#endif /* QEMU_PCIE_AER_H */
hw/pci/pcie_aer.c +2 -2
@@ -376,7 +376,7 @@ static void pcie_aer_msg_root_port(PCIDevice *dev, const PCIEAERMsg *msg)* * Walk up the bus tree from the device, propagate the error message. */ -void pcie_aer_msg (PCIDevice *dev,const PCIEAERMsg *msg) +static void pcie_aer_msg (PCIDevice *dev,const PCIEAERMsg *msg) {uint8_t type;
@@ -631,7 +631,7 @@ static bool pcie_aer_inject_uncor_error(PCIEAERInject *inj, bool is_fatal)* Figure 6-2: Flowchart Showing Sequence of Device Error Signaling and Logging * Operations */ -int pcie_aer_inject_error (PCIDevice *dev,const PCIEAERErr *err) +static int pcie_aer_inject_error (PCIDevice *dev,const PCIEAERErr *err) {uint8_t *aer_cap =NULL ;uint16_t devctl =0 ;
Signature · 1 line
2.9.3
PATCH v5 3/10 coccinelle: Add script to remove useless QObject casts
In reply to Eric BlakeWe have macros in place to make it less verbose to add a subtype of QObject to both QDict and QList. While we have made cleanups like this in the past (see commit fcfcd8ffc, for example), having it be automated by Coccinelle makes it easier to maintain.
The script is separate from the cleanups, for ease of review and backporting. A later patch will then add further possible cleanups.
---
v5: add R-b
v4: no change
v3: new patch
--- MAINTAINERS | 1 + scripts/coccinelle/qobject.cocci | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 scripts/coccinelle/qobject.cocci
MAINTAINERS +1 -0
@@ -1393,6 +1393,7 @@ S: Supported F: qobject/ F: include/qapi/qmp/ X: include/qapi/qmp/dispatch.h +F: scripts/coccinelle/qobject.cocci F: tests/check-qdict.c F: tests/check-qfloat.c F: tests/check-qint.c
scripts/coccinelle/qobject.cocci new file +13 -0
@@ -0,0 +1,13 @@ +// Use QDict macros where they make sense +@@ +expression Obj, Key, E; +@@ +- qdict_put_obj(Obj, Key, QOBJECT(E)); ++ qdict_put(Obj, Key, E); + +// Use QList macros where they make sense +@@ +expression Obj, E; +@@ +- qlist_append_obj(Obj, QOBJECT(E)); ++ qlist_append(Obj, E);
Signature · 1 line
2.9.3
PATCH v5 5/10 qobject: Add helper macros for common scalar insertions
In reply to Eric BlakeRather than making lots of callers wrap a scalar in a QInt, QString, or QBool, provide helper macros that do the wrapping automatically.
Update the Coccinelle script to make mass conversions easy, although the conversion itself will be done as a separate patches to ease review and backport efforts.
---
v5: minor comment tweak [Markus], add R-b
v4: tweak comment wording
v3: new patch
--- include/qapi/qmp/qdict.h | 8 ++++++++ include/qapi/qmp/qlist.h | 8 ++++++++ scripts/coccinelle/qobject.cocci | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+)
include/qapi/qmp/qdict.h +8 -0
@@ -52,6 +52,14 @@ void qdict_destroy_obj(QObject *obj);#define qdict_put (qdict, key, obj) \ qdict_put_obj(qdict, key, QOBJECT(obj)) +/* Helpers for int, bool, and string */ +#define qdict_put_int (qdict, key, value) \ + qdict_put(qdict, key, qint_from_int(value)) +#define qdict_put_bool (qdict, key, value) \ + qdict_put(qdict, key, qbool_from_bool(value)) +#define qdict_put_str (qdict, key, value) \ + qdict_put(qdict, key, qstring_from_str(value)) +/* High level helpers */ double qdict_get_double (const QDict *qdict,const char *key);int64_t qdict_get_int (const QDict *qdict,const char *key);
include/qapi/qmp/qlist.h +8 -0
@@ -29,6 +29,14 @@ typedef struct QList {#define qlist_append (qlist, obj) \ qlist_append_obj(qlist, QOBJECT(obj)) +/* Helpers for int, bool, and string */ +#define qlist_append_int (qlist, value) \ + qlist_append(qlist, qint_from_int(value)) +#define qlist_append_bool (qlist, value) \ + qlist_append(qlist, qbool_from_bool(value)) +#define qlist_append_str (qlist, value) \ + qlist_append(qlist, qstring_from_str(value)) +#define QLIST_FOREACH_ENTRY (qlist, var) \ for ((var) = ((qlist)->head.tqh_first); \ (var); \
scripts/coccinelle/qobject.cocci +22 -0
@@ -2,12 +2,34 @@ @@ expression Obj, Key, E; @@ +( - qdict_put_obj(Obj, Key, QOBJECT(E)); + qdict_put(Obj, Key, E); +| +- qdict_put(Obj, Key, qint_from_int(E)); ++ qdict_put_int(Obj, Key, E); +| +- qdict_put(Obj, Key, qbool_from_bool(E)); ++ qdict_put_bool(Obj, Key, E); +| +- qdict_put(Obj, Key, qstring_from_str(E)); ++ qdict_put_str(Obj, Key, E); +) // Use QList macros where they make sense @@ expression Obj, E; @@ +( - qlist_append_obj(Obj, QOBJECT(E)); + qlist_append(Obj, E); +| +- qlist_append(Obj, qint_from_int(E)); ++ qlist_append_int(Obj, E); +| +- qlist_append(Obj, qbool_from_bool(E)); ++ qlist_append_bool(Obj, E); +| +- qlist_append(Obj, qstring_from_str(E)); ++ qlist_append_str(Obj, E); +)
Signature · 1 line
2.9.3
PATCH v5 4/10 qobject: Drop useless QObject casts
In reply to Eric BlakeWe have macros in place to make it less verbose to add a subtype of QObject to both QDict and QList. While we have made cleanups like this in the past (see commit fcfcd8ffc, for example), having it be automated by Coccinelle makes it easier to maintain.
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-placethen I verified that no manual touchups were required.
---
v5: add R-b
v4: no change
v3: new patch
--- block.c | 12 ++++-------- block/blkdebug.c | 4 ++-- block/blkverify.c | 7 +++---- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/quorum.c | 16 ++++++---------- tests/check-qdict.c | 20 ++++++++++---------- tests/test-qmp-commands.c | 24 ++++++++++++------------ 8 files changed, 42 insertions(+), 51 deletions(-)
block.c +4 -8
@@ -4708,11 +4708,9 @@ void bdrv_refresh_filename(BlockDriverState *bs)* contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ if (bs->file->bs->full_open_options) { -qdict_put_obj (opts,"driver" , -QOBJECT (qstring_from_str (drv->format_name))); +qdict_put (opts,"driver" ,qstring_from_str (drv->format_name));QINCREF (bs->file->bs->full_open_options); -qdict_put_obj (opts,"file" , -QOBJECT (bs->file->bs->full_open_options)); +qdict_put (opts,"file" , bs->file->bs->full_open_options); bs->full_open_options = opts; }else {
@@ -4728,8 +4726,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) opts =qdict_new ();append_open_options (opts, bs); -qdict_put_obj (opts,"driver" , -QOBJECT (qstring_from_str (drv->format_name))); +qdict_put (opts,"driver" ,qstring_from_str (drv->format_name));if (bs->exact_filename[0 ]) {/* This may not work for all block protocol drivers (some may
@@ -4739,8 +4736,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* needs some special format of the options QDict, it needs to * implement the driver-specific bdrv_refresh_filename() function. */ -qdict_put_obj (opts,"filename" , -QOBJECT (qstring_from_str (bs->exact_filename))); +qdict_put (opts,"filename" ,qstring_from_str (bs->exact_filename)); } bs->full_open_options = opts;
block/blkdebug.c +2 -2
@@ -695,10 +695,10 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } opts =qdict_new (); -qdict_put_obj (opts,"driver" ,QOBJECT (qstring_from_str ("blkdebug" ))); +qdict_put (opts,"driver" ,qstring_from_str ("blkdebug" ));QINCREF (bs->file->bs->full_open_options); -qdict_put_obj (opts,"image" ,QOBJECT (bs->file->bs->full_open_options)); +qdict_put (opts,"image" , bs->file->bs->full_open_options);for (e =qdict_first (options); e; e =qdict_next (options, e)) {if (strcmp (qdict_entry_key (e),"x-image" )) {
block/blkverify.c +3 -4
@@ -291,13 +291,12 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) && s->test_file->bs->full_open_options) {QDict *opts =qdict_new (); -qdict_put_obj (opts,"driver" ,QOBJECT (qstring_from_str ("blkverify" ))); +qdict_put (opts,"driver" ,qstring_from_str ("blkverify" ));QINCREF (bs->file->bs->full_open_options); -qdict_put_obj (opts,"raw" ,QOBJECT (bs->file->bs->full_open_options)); +qdict_put (opts,"raw" , bs->file->bs->full_open_options);QINCREF (s->test_file->bs->full_open_options); -qdict_put_obj (opts,"test" , -QOBJECT (s->test_file->bs->full_open_options)); +qdict_put (opts,"test" , s->test_file->bs->full_open_options); bs->full_open_options = opts; }
block/file-posix.c +3 -3
@@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put_obj (options,"filename" ,QOBJECT (qstring_from_str (filename))); +qdict_put (options,"filename" ,qstring_from_str (filename)); }static QemuOptsList raw_runtime_opts = {
@@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put_obj (options,"filename" ,QOBJECT (qstring_from_str (filename))); +qdict_put (options,"filename" ,qstring_from_str (filename)); }static bool hdev_is_sg (BlockDriverState *bs)
@@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_cdrom:" , &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); }#endif
block/file-win32.c +2 -2
@@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put_obj (options,"filename" ,QOBJECT (qstring_from_str (filename))); +qdict_put (options,"filename" ,qstring_from_str (filename)); }static QemuOptsList raw_runtime_opts = {
@@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put_obj (options,"filename" ,QOBJECT (qstring_from_str (filename))); +qdict_put (options,"filename" ,qstring_from_str (filename)); } static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
block/quorum.c +6 -10
@@ -1096,19 +1096,15 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) children =qlist_new ();for (i =0 ; i < s->num_children; i++) {QINCREF (s->children[i]->bs->full_open_options); -qlist_append_obj (children, -QOBJECT (s->children[i]->bs->full_open_options)); +qlist_append (children, s->children[i]->bs->full_open_options); } opts =qdict_new (); -qdict_put_obj (opts,"driver" ,QOBJECT (qstring_from_str ("quorum" ))); -qdict_put_obj (opts,QUORUM_OPT_VOTE_THRESHOLD , -QOBJECT (qint_from_int (s->threshold))); -qdict_put_obj (opts,QUORUM_OPT_BLKVERIFY , -QOBJECT (qbool_from_bool (s->is_blkverify))); -qdict_put_obj (opts,QUORUM_OPT_REWRITE , -QOBJECT (qbool_from_bool (s->rewrite_corrupted))); -qdict_put_obj (opts,"children" ,QOBJECT (children)); +qdict_put (opts,"driver" ,qstring_from_str ("quorum" )); +qdict_put (opts,QUORUM_OPT_VOTE_THRESHOLD ,qint_from_int (s->threshold)); +qdict_put (opts,QUORUM_OPT_BLKVERIFY ,qbool_from_bool (s->is_blkverify)); +qdict_put (opts,QUORUM_OPT_REWRITE ,qbool_from_bool (s->rewrite_corrupted)); +qdict_put (opts,"children" , children); bs->full_open_options = opts; }
tests/check-qdict.c +10 -10
@@ -47,7 +47,7 @@ static void qdict_put_obj_test(void) qdict =qdict_new ();// key "" will have tdb hash 12345 -qdict_put_obj (qdict,"" ,QOBJECT (qint_from_int (num))); +qdict_put (qdict,"" ,qint_from_int (num));g_assert (qdict_size (qdict) ==1 ); ent =QLIST_FIRST (&qdict->table[12345 %QDICT_BUCKET_MAX ]);
@@ -66,8 +66,8 @@ static void qdict_destroy_simple_test(void)QDict *qdict; qdict =qdict_new (); -qdict_put_obj (qdict,"num" ,QOBJECT (qint_from_int (0 ))); -qdict_put_obj (qdict,"str" ,QOBJECT (qstring_from_str ("foo" ))); +qdict_put (qdict,"num" ,qint_from_int (0 )); +qdict_put (qdict,"str" ,qstring_from_str ("foo" ));QDECREF (qdict); }
@@ -297,16 +297,16 @@ static void qdict_flatten_test(void)qdict_put (dict1,"a" ,qint_from_int (0 ));qdict_put (dict1,"b" ,qint_from_int (1 )); -qlist_append_obj (list1,QOBJECT (qint_from_int (23 ))); -qlist_append_obj (list1,QOBJECT (qint_from_int (66 ))); -qlist_append_obj (list1,QOBJECT (dict1)); -qlist_append_obj (list2,QOBJECT (qint_from_int (42 ))); -qlist_append_obj (list2,QOBJECT (list1)); +qlist_append (list1,qint_from_int (23 )); +qlist_append (list1,qint_from_int (66 )); +qlist_append (list1, dict1); +qlist_append (list2,qint_from_int (42 )); +qlist_append (list2, list1);qdict_put (dict2,"c" ,qint_from_int (2 ));qdict_put (dict2,"d" ,qint_from_int (3 )); -qdict_put_obj (dict3,"e" ,QOBJECT (list2)); -qdict_put_obj (dict3,"f" ,QOBJECT (dict2)); +qdict_put (dict3,"e" , list2); +qdict_put (dict3,"f" , dict2);qdict_put (dict3,"g" ,qint_from_int (4 ));qdict_flatten (dict3);
tests/test-qmp-commands.c +12 -12
@@ -94,7 +94,7 @@ static void test_dispatch_cmd(void)QDict *req =qdict_new ();QObject *resp; -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd" ))); +qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -111,7 +111,7 @@ static void test_dispatch_cmd_failure(void)QDict *args =qdict_new ();QObject *resp; -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd2" ))); +qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -125,7 +125,7 @@ static void test_dispatch_cmd_failure(void)qdict_put (args,"a" ,qint_from_int (66 ));qdict_put (req,"arguments" , args); -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd" ))); +qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -164,14 +164,14 @@ static void test_dispatch_cmd_io(void)QDict *ret_dict_dict2, *ret_dict_dict2_userdef;QInt *ret3; -qdict_put_obj (ud1a,"integer" ,QOBJECT (qint_from_int (42 ))); -qdict_put_obj (ud1a,"string" ,QOBJECT (qstring_from_str ("hello" ))); -qdict_put_obj (ud1b,"integer" ,QOBJECT (qint_from_int (422 ))); -qdict_put_obj (ud1b,"string" ,QOBJECT (qstring_from_str ("hello2" ))); -qdict_put_obj (args,"ud1a" ,QOBJECT (ud1a)); -qdict_put_obj (args,"ud1b" ,QOBJECT (ud1b)); -qdict_put_obj (req,"arguments" ,QOBJECT (args)); -qdict_put_obj (req,"execute" ,QOBJECT (qstring_from_str ("user_def_cmd2" ))); +qdict_put (ud1a,"integer" ,qint_from_int (42 )); +qdict_put (ud1a,"string" ,qstring_from_str ("hello" )); +qdict_put (ud1b,"integer" ,qint_from_int (422 )); +qdict_put (ud1b,"string" ,qstring_from_str ("hello2" )); +qdict_put (args,"ud1a" , ud1a); +qdict_put (args,"ud1b" , ud1b); +qdict_put (req,"arguments" , args); +qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); ret =qobject_to_qdict (test_qmp_dispatch (req));
@@ -244,7 +244,7 @@ static void test_dealloc_partial(void)Visitor *v; ud2_dict =qdict_new (); -qdict_put_obj (ud2_dict,"string0" ,QOBJECT (qstring_from_str (text))); +qdict_put (ud2_dict,"string0" ,qstring_from_str (text)); v =qobject_input_visitor_new (QOBJECT (ud2_dict));visit_type_UserDefTwo (v,NULL , &ud2, &err);
Signature · 1 line
2.9.3
PATCH v5 6/10 qobject: Use simpler QDict/QList scalar insertion macros
In reply to Eric BlakeWe now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in monitor.c.
---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
v4: no change
v3: new patch
--- block.c | 45 +++++------- block/blkdebug.c | 6 +- block/blkverify.c | 6 +- block/curl.c | 2 +- block/file-posix.c | 8 +-- block/file-win32.c | 4 +- block/nbd.c | 41 ++++++----- block/nfs.c | 43 +++++------- block/null.c | 2 +- block/qcow2.c | 4 +- block/quorum.c | 8 +-- block/rbd.c | 16 ++--- block/snapshot.c | 2 +- block/ssh.c | 16 ++--- block/vvfat.c | 10 +-- block/vxhs.c | 6 +- blockdev.c | 30 ++++---- hw/block/xen_disk.c | 2 +- hw/usb/xen-usb.c | 12 ++-- monitor.c | 23 +++---- qapi/qmp-event.c | 2 +- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qobject/qdict.c | 2 +- target/s390x/cpu_models.c | 4 +- tests/check-qdict.c | 134 ++++++++++++++++++------------------ tests/check-qlist.c | 4 +- tests/device-introspect-test.c | 4 +- tests/test-qemu-opts.c | 4 +- tests/test-qmp-commands.c | 24 +++---- tests/test-qmp-event.c | 30 ++++---- tests/test-qobject-output-visitor.c | 6 +- util/qemu-option.c | 2 +- 34 files changed, 244 insertions(+), 268 deletions(-)
block.c +19 -26
@@ -974,16 +974,14 @@ static void update_flags_from_options(int *flags, QemuOpts *opts)static void update_options_from_flags (QDict *options,int flags) {if (!qdict_haskey (options,BDRV_OPT_CACHE_DIRECT )) { -qdict_put (options,BDRV_OPT_CACHE_DIRECT , -qbool_from_bool (flags &BDRV_O_NOCACHE )); +qdict_put_bool (options,BDRV_OPT_CACHE_DIRECT , flags &BDRV_O_NOCACHE ); }if (!qdict_haskey (options,BDRV_OPT_CACHE_NO_FLUSH )) { -qdict_put (options,BDRV_OPT_CACHE_NO_FLUSH , -qbool_from_bool (flags &BDRV_O_NO_FLUSH )); +qdict_put_bool (options,BDRV_OPT_CACHE_NO_FLUSH , + flags &BDRV_O_NO_FLUSH ); }if (!qdict_haskey (options,BDRV_OPT_READ_ONLY )) { -qdict_put (options,BDRV_OPT_READ_ONLY , -qbool_from_bool (!(flags &BDRV_O_RDWR ))); +qdict_put_bool (options,BDRV_OPT_READ_ONLY , !(flags &BDRV_O_RDWR )); } }
@@ -1399,7 +1397,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,/* Fetch the file name from the options QDict if necessary */ if (protocol && filename) {if (!qdict_haskey (*options,"filename" )) { -qdict_put (*options,"filename" ,qstring_from_str (filename)); +qdict_put_str (*options,"filename" , filename); parse_filename = true; }else { error_setg(errp, "Can't specify 'file' and 'filename' options at "
@@ -1420,7 +1418,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, } drvname = drv->format_name; -qdict_put (*options,"driver" ,qstring_from_str (drvname)); +qdict_put_str (*options,"driver" , drvname); }else {error_setg (errp,"Must specify either driver or file" );return -EINVAL ;
@@ -2075,7 +2073,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, }if (bs->backing_format[0 ] !='\0' && !qdict_haskey (options,"driver" )) { -qdict_put (options,"driver" ,qstring_from_str (bs->backing_format)); +qdict_put_str (options,"driver" , bs->backing_format); } backing_hd = bdrv_open_inherit(*backing_filename ? backing_filename : NULL,
@@ -2230,12 +2228,9 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, }/* Prepare options QDict for the temporary file */ -qdict_put (snapshot_options,"file.driver" , -qstring_from_str ("file" )); -qdict_put (snapshot_options,"file.filename" , -qstring_from_str (tmp_filename)); -qdict_put (snapshot_options,"driver" , -qstring_from_str ("qcow2" )); +qdict_put_str (snapshot_options,"file.driver" ,"file" ); +qdict_put_str (snapshot_options,"file.filename" , tmp_filename); +qdict_put_str (snapshot_options,"driver" ,"qcow2" ); bs_snapshot =bdrv_open (NULL ,NULL , snapshot_options, flags, errp); snapshot_options =NULL ;
@@ -2410,8 +2405,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, goto fail; } -qdict_put (options,"file" , -qstring_from_str (bdrv_get_node_name (file_bs))); +qdict_put_str (options,"file" ,bdrv_get_node_name (file_bs)); } }
@@ -2433,8 +2427,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,* sure to update both bs->options (which has the full effective * options for bs) and options (which has file.* already removed). */ -qdict_put (bs->options,"driver" ,qstring_from_str (drv->format_name)); -qdict_put (options,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (bs->options,"driver" , drv->format_name); +qdict_put_str (options,"driver" , drv->format_name); }else if (!drv) {error_setg (errp,"Must specify either driver or file" ); goto fail;
@@ -2810,12 +2804,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,* that they are checked at the end of this function. */ value =qemu_opt_get (opts,"node-name" );if (value) { -qdict_put (reopen_state->options,"node-name" ,qstring_from_str (value)); +qdict_put_str (reopen_state->options,"node-name" , value); } value =qemu_opt_get (opts,"driver" );if (value) { -qdict_put (reopen_state->options,"driver" ,qstring_from_str (value)); +qdict_put_str (reopen_state->options,"driver" , value); }/* If we are to stay read-only, do not allow permission change
@@ -4302,8 +4296,7 @@ void bdrv_img_create(const char *filename, const char *fmt,if (backing_fmt) { backing_options =qdict_new (); -qdict_put (backing_options,"driver" , -qstring_from_str (backing_fmt)); +qdict_put_str (backing_options,"driver" , backing_fmt); } bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
@@ -4708,7 +4701,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ if (bs->file->bs->full_open_options) { -qdict_put (opts,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (opts,"driver" , drv->format_name);QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"file" , bs->file->bs->full_open_options);
@@ -4726,7 +4719,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) opts =qdict_new ();append_open_options (opts, bs); -qdict_put (opts,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (opts,"driver" , drv->format_name);if (bs->exact_filename[0 ]) {/* This may not work for all block protocol drivers (some may
@@ -4736,7 +4729,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* needs some special format of the options QDict, it needs to * implement the driver-specific bdrv_refresh_filename() function. */ -qdict_put (opts,"filename" ,qstring_from_str (bs->exact_filename)); +qdict_put_str (opts,"filename" , bs->exact_filename); } bs->full_open_options = opts;
block/blkdebug.c +3 -3
@@ -301,7 +301,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,if (!strstart (filename,"blkdebug:" , &filename)) {/* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename);return ; }
@@ -320,7 +320,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,/* TODO Allow multi-level nesting and set file.filename here */ filename = c +1 ; -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename); }static QemuOptsList runtime_opts = {
@@ -695,7 +695,7 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("blkdebug" )); +qdict_put_str (opts,"driver" ,"blkdebug" );QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"image" , bs->file->bs->full_open_options);
block/blkverify.c +3 -3
@@ -67,7 +67,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,if (!strstart (filename,"blkverify:" , &filename)) {/* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename);return ; }
@@ -84,7 +84,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,/* TODO Allow multi-level nesting and set file.filename here */ filename = c +1 ; -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename); }static QemuOptsList runtime_opts = {
@@ -291,7 +291,7 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) && s->test_file->bs->full_open_options) {QDict *opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("blkverify" )); +qdict_put_str (opts,"driver" ,"blkverify" );QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"raw" , bs->file->bs->full_open_options);
block/curl.c +1 -1
@@ -548,7 +548,7 @@ static void curl_clean_state(CURLState *s)static void curl_parse_filename (const char *filename,QDict *options,Error **errp) { -qdict_put (options,CURL_BLOCK_OPT_URL ,qstring_from_str (filename)); +qdict_put_str (options,CURL_BLOCK_OPT_URL , filename); }static void curl_detach_aio_context (BlockDriverState *bs)
block/file-posix.c +4 -4
@@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static QemuOptsList raw_runtime_opts = {
@@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static bool hdev_is_sg (BlockDriverState *bs)
@@ -2239,7 +2239,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, goto hdev_open_Mac_error; } -qdict_put (options,"filename" ,qstring_from_str (bsd_path)); +qdict_put_str (options,"filename" , bsd_path); hdev_open_Mac_error:g_free (mediaType);
@@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_cdrom:" , &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); }#endif
block/file-win32.c +2 -2
@@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static QemuOptsList raw_runtime_opts = {
@@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); } static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
block/nbd.c +20 -21
101 lines not on this page · raw message
block/nfs.c +17 -26
84 lines not on this page · raw message
block/null.c +1 -1
@@ -232,7 +232,7 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts) bs->drv->format_name); } -qdict_put (opts,"driver" ,qstring_from_str (bs->drv->format_name)); +qdict_put_str (opts,"driver" , bs->drv->format_name); bs->full_open_options = opts; }
block/qcow2.c +2 -2
@@ -2265,7 +2265,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,* table) */ options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str ("qcow2" )); +qdict_put_str (options,"driver" ,"qcow2" ); blk =blk_new_open (filename,NULL , options,BDRV_O_RDWR |BDRV_O_RESIZE |BDRV_O_NO_FLUSH , &local_err);
@@ -2327,7 +2327,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */ options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str ("qcow2" )); +qdict_put_str (options,"driver" ,"qcow2" ); blk =blk_new_open (filename,NULL , options,BDRV_O_RDWR |BDRV_O_NO_BACKING , &local_err);if (blk ==NULL ) {
block/quorum.c +4 -4
@@ -1100,10 +1100,10 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) } opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("quorum" )); -qdict_put (opts,QUORUM_OPT_VOTE_THRESHOLD ,qint_from_int (s->threshold)); -qdict_put (opts,QUORUM_OPT_BLKVERIFY ,qbool_from_bool (s->is_blkverify)); -qdict_put (opts,QUORUM_OPT_REWRITE ,qbool_from_bool (s->rewrite_corrupted)); +qdict_put_str (opts,"driver" ,"quorum" ); +qdict_put_int (opts,QUORUM_OPT_VOTE_THRESHOLD , s->threshold); +qdict_put_bool (opts,QUORUM_OPT_BLKVERIFY , s->is_blkverify); +qdict_put_bool (opts,QUORUM_OPT_REWRITE , s->rewrite_corrupted);qdict_put (opts,"children" , children); bs->full_open_options = opts;
block/rbd.c +8 -8
@@ -154,20 +154,20 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, goto done; }qemu_rbd_unescape (found_str); -qdict_put (options,"pool" ,qstring_from_str (found_str)); +qdict_put_str (options,"pool" , found_str);if (strchr (p,'@' )) { found_str =qemu_rbd_next_tok (p,'@' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"image" ,qstring_from_str (found_str)); +qdict_put_str (options,"image" , found_str); found_str =qemu_rbd_next_tok (p,':' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"snapshot" ,qstring_from_str (found_str)); +qdict_put_str (options,"snapshot" , found_str); }else { found_str =qemu_rbd_next_tok (p,':' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"image" ,qstring_from_str (found_str)); +qdict_put_str (options,"image" , found_str); }if (!p) { goto done;
@@ -189,9 +189,9 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,qemu_rbd_unescape (value);if (!strcmp (name,"conf" )) { -qdict_put (options,"conf" ,qstring_from_str (value)); +qdict_put_str (options,"conf" , value); }else if (!strcmp (name,"id" )) { -qdict_put (options,"user" ,qstring_from_str (value)); +qdict_put_str (options,"user" , value); }else {/* * We pass these internally to qemu_rbd_set_keypairs(), so
@@ -204,8 +204,8 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,if (!keypairs) { keypairs =qlist_new (); } -qlist_append (keypairs,qstring_from_str (name)); -qlist_append (keypairs,qstring_from_str (value)); +qlist_append_str (keypairs, name); +qlist_append_str (keypairs, value); } }
block/snapshot.c +1 -1
@@ -200,7 +200,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,qdict_extract_subqdict (options, &file_options,"file." );QDECREF (file_options); -qdict_put (options,"file" ,qstring_from_str (bdrv_get_node_name (file))); +qdict_put_str (options,"file" ,bdrv_get_node_name (file)); drv->bdrv_close (bs);bdrv_unref_child (bs, bs->file);
block/ssh.c +7 -9
@@ -227,24 +227,23 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) }if (uri->user &&strcmp (uri->user,"" ) !=0 ) { -qdict_put (options,"user" ,qstring_from_str (uri->user)); +qdict_put_str (options,"user" , uri->user); } -qdict_put (options,"server.host" ,qstring_from_str (uri->server)); +qdict_put_str (options,"server.host" , uri->server); port_str =g_strdup_printf ("%d" , uri->port ?:22 ); -qdict_put (options,"server.port" ,qstring_from_str (port_str)); +qdict_put_str (options,"server.port" , port_str);g_free (port_str); -qdict_put (options,"path" ,qstring_from_str (uri->path)); +qdict_put_str (options,"path" , uri->path);/* Pick out any query parameters that we understand, and ignore * the rest. */ for (i =0 ; i < qp->n; ++i) {if (strcmp (qp->p[i].name,"host_key_check" ) ==0 ) { -qdict_put (options,"host_key_check" , -qstring_from_str (qp->p[i].value)); +qdict_put_str (options,"host_key_check" , qp->p[i].value); } }
@@ -574,9 +573,8 @@ static bool ssh_process_legacy_socket_options(QDict *output_opts, }if (host) { -qdict_put (output_opts,"server.host" ,qstring_from_str (host)); -qdict_put (output_opts,"server.port" , -qstring_from_str (port ?:stringify (22 ))); +qdict_put_str (output_opts,"server.host" , host); +qdict_put_str (output_opts,"server.port" , port ?:stringify (22 )); }return true;
block/vvfat.c +5 -5
@@ -1057,10 +1057,10 @@ static void vvfat_parse_filename(const char *filename, QDict *options, }/* Fill in the options QDict */ -qdict_put (options,"dir" ,qstring_from_str (filename)); -qdict_put (options,"fat-type" ,qint_from_int (fat_type)); -qdict_put (options,"floppy" ,qbool_from_bool (floppy)); -qdict_put (options,"rw" ,qbool_from_bool (rw)); +qdict_put_str (options,"dir" , filename); +qdict_put_int (options,"fat-type" , fat_type); +qdict_put_bool (options,"floppy" , floppy); +qdict_put_bool (options,"rw" , rw); } static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
@@ -3051,7 +3051,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp) } options =qdict_new (); -qdict_put (options,"write-target.driver" ,qstring_from_str ("qcow" )); +qdict_put_str (options,"write-target.driver" ,"qcow" ); s->qcow =bdrv_open_child (s->qcow_filename, options,"write-target" , bs, &child_vvfat_qcow, false, errp);QDECREF (options);
block/vxhs.c +3 -3
@@ -182,15 +182,15 @@ static int vxhs_parse_uri(const char *filename, QDict *options)return -EINVAL ; } -qdict_put (options,VXHS_OPT_SERVER ".host" ,qstring_from_str (uri->server)); +qdict_put_str (options,VXHS_OPT_SERVER ".host" , uri->server);if (uri->port) { port =g_strdup_printf ("%d" , uri->port); -qdict_put (options,VXHS_OPT_SERVER ".port" ,qstring_from_str (port)); +qdict_put_str (options,VXHS_OPT_SERVER ".port" , port);g_free (port); } -qdict_put (options,"vdisk-id" ,qstring_from_str (uri->path)); +qdict_put_str (options,"vdisk-id" , uri->path);trace_vxhs_parse_uri_hostinfo (uri->server, uri->port);uri_free (uri);
blockdev.c +13 -17
@@ -527,7 +527,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,error_setg (errp,"Cannot specify both 'driver' and 'format'" ); goto early_err; } -qdict_put (bs_opts,"driver" ,qstring_from_str (buf)); +qdict_put_str (bs_opts,"driver" , buf); } on_write_error =BLOCKDEV_ON_ERROR_ENOSPC ;
@@ -903,10 +903,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) copy_on_read = false; } -qdict_put (bs_opts,BDRV_OPT_READ_ONLY , -qstring_from_str (read_only ?"on" :"off" )); -qdict_put (bs_opts,"copy-on-read" , -qstring_from_str (copy_on_read ?"on" :"off" )); +qdict_put_str (bs_opts,BDRV_OPT_READ_ONLY , read_only ?"on" :"off" ); +qdict_put_str (bs_opts,"copy-on-read" , copy_on_read ?"on" :"off" );/* Controller type */ value =qemu_opt_get (legacy_opts,"if" );
@@ -1030,7 +1028,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) new_id =g_strdup_printf ("%s%s%i" , if_name[type], mediastr, unit_id); } -qdict_put (bs_opts,"id" ,qstring_from_str (new_id)); +qdict_put_str (bs_opts,"id" , new_id);g_free (new_id); }
@@ -1067,7 +1065,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)error_report ("werror is not supported by this bus type" ); goto fail; } -qdict_put (bs_opts,"werror" ,qstring_from_str (werror)); +qdict_put_str (bs_opts,"werror" , werror); } rerror =qemu_opt_get (legacy_opts,"rerror" );
@@ -1077,7 +1075,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)error_report ("rerror is not supported by this bus type" ); goto fail; } -qdict_put (bs_opts,"rerror" ,qstring_from_str (rerror)); +qdict_put_str (bs_opts,"rerror" , rerror); }/* Actual block device init: Functionality shared with blockdev-add */
@@ -1737,10 +1735,9 @@ static void external_snapshot_prepare(BlkActionState *common, options =qdict_new ();if (s->has_snapshot_node_name) { -qdict_put (options,"node-name" , -qstring_from_str (snapshot_node_name)); +qdict_put_str (options,"node-name" , snapshot_node_name); } -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); flags |=BDRV_O_NO_BACKING ; }
@@ -2579,11 +2576,10 @@ void qmp_blockdev_change_medium(bool has_device, const char *device, options =qdict_new (); detect_zeroes =blk_get_detect_zeroes_from_root_state (blk); -qdict_put (options,"detect-zeroes" , -qstring_from_str (detect_zeroes ?"on" :"off" )); +qdict_put_str (options,"detect-zeroes" , detect_zeroes ?"on" :"off" );if (has_format) { -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); } medium_bs =bdrv_open (filename,NULL , options, bdrv_flags, errp);
@@ -3251,7 +3247,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,if (backup->format) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (backup->format)); +qdict_put_str (options,"driver" , backup->format); } target_bs =bdrv_open (backup->target,NULL , options, flags, errp);
@@ -3555,10 +3551,10 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) options =qdict_new ();if (arg->has_node_name) { -qdict_put (options,"node-name" ,qstring_from_str (arg->node_name)); +qdict_put_str (options,"node-name" , arg->node_name); }if (format) { -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); }/* Mirroring takes care of copy-on-write using the source's backing
hw/block/xen_disk.c +1 -1
@@ -1082,7 +1082,7 @@ static int blk_connect(struct XenDevice *xendev)if (strcmp (blkdev->fileproto,"<unset>" )) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (blkdev->fileproto)); +qdict_put_str (options,"driver" , blkdev->fileproto); }/* setup via xenbus -> create new block driver instance */
hw/usb/xen-usb.c +6 -6
@@ -746,16 +746,16 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port, portname++; qdict =qdict_new (); -qdict_put (qdict,"driver" ,qstring_from_str ("usb-host" )); +qdict_put_str (qdict,"driver" ,"usb-host" ); tmp =g_strdup_printf ("%s.0" , usbif->xendev.qdev.id); -qdict_put (qdict,"bus" ,qstring_from_str (tmp)); +qdict_put_str (qdict,"bus" , tmp);g_free (tmp); tmp =g_strdup_printf ("%s-%u" , usbif->xendev.qdev.id, port); -qdict_put (qdict,"id" ,qstring_from_str (tmp)); +qdict_put_str (qdict,"id" , tmp);g_free (tmp); -qdict_put (qdict,"port" ,qint_from_int (port)); -qdict_put (qdict,"hostbus" ,qint_from_int (atoi (busid))); -qdict_put (qdict,"hostport" ,qstring_from_str (portname)); +qdict_put_int (qdict,"port" , port); +qdict_put_int (qdict,"hostbus" ,atoi (busid)); +qdict_put_str (qdict,"hostport" , portname); opts =qemu_opts_from_qdict (qemu_find_opts ("device" ), qdict, &local_err);if (local_err) { goto err;
monitor.c +11 -12
@@ -2777,7 +2777,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } goto fail; } -qdict_put (qdict, key,qstring_from_str (buf)); +qdict_put_str (qdict, key, buf); }break ;case 'O' :
@@ -2879,9 +2879,9 @@ static QDict *monitor_parse_arguments(Monitor *mon, size =-1 ; } } -qdict_put (qdict,"count" ,qint_from_int (count)); -qdict_put (qdict,"format" ,qint_from_int (format)); -qdict_put (qdict,"size" ,qint_from_int (size)); +qdict_put_int (qdict,"count" , count); +qdict_put_int (qdict,"format" , format); +qdict_put_int (qdict,"size" , size); }break ;case 'i' :
@@ -2924,7 +2924,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } val <<=20 ; } -qdict_put (qdict, key,qint_from_int (val)); +qdict_put_int (qdict, key, val); }break ;case 'o' :
@@ -2947,7 +2947,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,monitor_printf (mon,"invalid size\n" ); goto fail; } -qdict_put (qdict, key,qint_from_int (val)); +qdict_put_int (qdict, key, val); p = end; }break ;
@@ -3003,7 +3003,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,monitor_printf (mon,"Expected 'on' or 'off'\n" ); goto fail; } -qdict_put (qdict, key,qbool_from_bool (val)); +qdict_put_bool (qdict, key, val); }break ;case '-' :
@@ -3034,7 +3034,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, }else {/* has option */ p++; -qdict_put (qdict, key,qbool_from_bool (true)); +qdict_put_bool (qdict, key, true); } } }
@@ -3060,7 +3060,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, cmd->name); goto fail; } -qdict_put (qdict, key,qstring_from_str (p)); +qdict_put_str (qdict, key, p); p += len; }break ;
@@ -3839,9 +3839,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) {/* Provide a more useful error message */ qdict_del (qdict,"desc" ); -qdict_put (qdict,"desc" , -qstring_from_str ("Expecting capabilities negotiation" -" with 'qmp_capabilities'" )); +qdict_put_str (qdict,"desc" ,"Expecting capabilities negotiation" +" with 'qmp_capabilities'" ); } }
qapi/qmp-event.c +1 -1
@@ -51,7 +51,7 @@ static void timestamp_put(QDict *qdict)QDict *qmp_event_build_dict (const char *event_name) {QDict *dict =qdict_new (); -qdict_put (dict,"event" ,qstring_from_str (event_name)); +qdict_put_str (dict,"event" , event_name);timestamp_put (dict);return dict; }
qemu-img.c +3 -3
@@ -313,7 +313,7 @@ static BlockBackend *img_open_file(const char *filename,if (fmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (fmt)); +qdict_put_str (options,"driver" , fmt); } blk =blk_new_open (filename,NULL , options, flags, &local_err);
@@ -3158,7 +3158,7 @@ static int img_rebase(int argc, char **argv)if (bs->backing_format[0 ] !='\0' ) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (bs->backing_format)); +qdict_put_str (options,"driver" , bs->backing_format); }bdrv_get_backing_filename (bs, backing_name,sizeof (backing_name));
@@ -3175,7 +3175,7 @@ static int img_rebase(int argc, char **argv)if (out_baseimg[0 ]) {if (out_basefmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (out_basefmt)); +qdict_put_str (options,"driver" , out_basefmt); }else { options =NULL ; }
qemu-io.c +1 -1
@@ -601,7 +601,7 @@ int main(int argc, char **argv) }else {if (format) { opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str (format)); +qdict_put_str (opts,"driver" , format); }if (openfile (argv[optind], flags, writethrough, opts)) {exit (1 );
qemu-nbd.c +1 -1
@@ -959,7 +959,7 @@ int main(int argc, char **argv) }else {if (fmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (fmt)); +qdict_put_str (options,"driver" , fmt); } blk =blk_new_open (srcpath,NULL , options, flags, &local_err); }
qobject/qdict.c +1 -1
@@ -463,7 +463,7 @@ void qdict_set_default_str(QDict *dst, const char *key, const char *val)return ; } -qdict_put (dst, key,qstring_from_str (val)); +qdict_put_str (dst, key, val); } static void qdict_flatten_qdict(QDict *qdict, QDict *target,
target/s390x/cpu_models.c +2 -2
@@ -376,12 +376,12 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,static void qdict_add_disabled_feat (const char *name,void *opaque) { -qdict_put (opaque, name,qbool_from_bool (false)); +qdict_put_bool (opaque, name, false); }static void qdict_add_enabled_feat (const char *name,void *opaque) { -qdict_put (opaque, name,qbool_from_bool (true)); +qdict_put_bool (opaque, name, true); }/* convert S390CPUDef into a static CpuModelInfo */
tests/check-qdict.c +67 -67
302 lines not on this page · raw message
tests/check-qlist.c +2 -2
@@ -74,7 +74,7 @@ static void qlist_destroy_test(void) qlist =qlist_new ();for (i =0 ; i <42 ; i++) -qlist_append (qlist,qint_from_int (i)); +qlist_append_int (qlist, i);QDECREF (qlist); }
@@ -103,7 +103,7 @@ static void qlist_iter_test(void) qlist =qlist_new ();for (i =0 ; i < iter_max; i++) -qlist_append (qlist,qint_from_int (i)); +qlist_append_int (qlist, i); iter_called =0 ;qlist_iter (qlist, iter_func,NULL );
tests/device-introspect-test.c +2 -2
@@ -32,9 +32,9 @@ static QList *qom_list_types(const char *implements, bool abstract)QList *ret;QDict *args =qdict_new (); -qdict_put (args,"abstract" ,qbool_from_bool (abstract)); +qdict_put_bool (args,"abstract" , abstract);if (implements) { -qdict_put (args,"implements" ,qstring_from_str (implements)); +qdict_put_str (args,"implements" , implements); } resp =qmp ("{'execute': 'qom-list-types'," " 'arguments': %p }" , args);
tests/test-qemu-opts.c +2 -2
@@ -299,7 +299,7 @@ static void test_qemu_opt_get_size(void) dict =qdict_new ();g_assert (dict !=NULL ); -qdict_put (dict,"size1" ,qstring_from_str ("10" )); +qdict_put_str (dict,"size1" ,"10" );qemu_opts_absorb_qdict (opts, dict, &error_abort);g_assert (error_abort ==NULL );
@@ -309,7 +309,7 @@ static void test_qemu_opt_get_size(void)g_assert (opt ==10 );/* reset value */ -qdict_put (dict,"size1" ,qstring_from_str ("15" )); +qdict_put_str (dict,"size1" ,"15" );qemu_opts_absorb_qdict (opts, dict, &error_abort);g_assert (error_abort ==NULL );
tests/test-qmp-commands.c +12 -12
@@ -94,7 +94,7 @@ static void test_dispatch_cmd(void)QDict *req =qdict_new ();QObject *resp; -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); +qdict_put_str (req,"execute" ,"user_def_cmd" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -111,7 +111,7 @@ static void test_dispatch_cmd_failure(void)QDict *args =qdict_new ();QObject *resp; -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); +qdict_put_str (req,"execute" ,"user_def_cmd2" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -122,10 +122,10 @@ static void test_dispatch_cmd_failure(void)/* check that with extra arguments it throws an error */ req =qdict_new (); -qdict_put (args,"a" ,qint_from_int (66 )); +qdict_put_int (args,"a" ,66 );qdict_put (req,"arguments" , args); -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); +qdict_put_str (req,"execute" ,"user_def_cmd" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -164,14 +164,14 @@ static void test_dispatch_cmd_io(void)QDict *ret_dict_dict2, *ret_dict_dict2_userdef;QInt *ret3; -qdict_put (ud1a,"integer" ,qint_from_int (42 )); -qdict_put (ud1a,"string" ,qstring_from_str ("hello" )); -qdict_put (ud1b,"integer" ,qint_from_int (422 )); -qdict_put (ud1b,"string" ,qstring_from_str ("hello2" )); +qdict_put_int (ud1a,"integer" ,42 ); +qdict_put_str (ud1a,"string" ,"hello" ); +qdict_put_int (ud1b,"integer" ,422 ); +qdict_put_str (ud1b,"string" ,"hello2" );qdict_put (args,"ud1a" , ud1a);qdict_put (args,"ud1b" , ud1b);qdict_put (req,"arguments" , args); -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); +qdict_put_str (req,"execute" ,"user_def_cmd2" ); ret =qobject_to_qdict (test_qmp_dispatch (req));
@@ -190,9 +190,9 @@ static void test_dispatch_cmd_io(void)assert (!strcmp (qdict_get_str (ret_dict_dict2,"string" ),"blah4" ));QDECREF (ret); -qdict_put (args3,"a" ,qint_from_int (66 )); +qdict_put_int (args3,"a" ,66 );qdict_put (req,"arguments" , args3); -qdict_put (req,"execute" ,qstring_from_str ("guest-get-time" )); +qdict_put_str (req,"execute" ,"guest-get-time" ); ret3 =qobject_to_qint (test_qmp_dispatch (req));assert (qint_get_int (ret3) ==66 );
@@ -244,7 +244,7 @@ static void test_dealloc_partial(void)Visitor *v; ud2_dict =qdict_new (); -qdict_put (ud2_dict,"string0" ,qstring_from_str (text)); +qdict_put_str (ud2_dict,"string0" , text); v =qobject_input_visitor_new (QOBJECT (ud2_dict));visit_type_UserDefTwo (v,NULL , &ud2, &err);
tests/test-qmp-event.c +15 -15
@@ -153,7 +153,7 @@ static void test_event_a(TestEventData *data, {QDict *d; d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_A" )); +qdict_put_str (d,"event" ,"EVENT_A" );qapi_event_send_event_a (&error_abort); }
@@ -162,7 +162,7 @@ static void test_event_b(TestEventData *data, {QDict *d; d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_B" )); +qdict_put_str (d,"event" ,"EVENT_B" );qapi_event_send_event_b (&error_abort); }
@@ -177,16 +177,16 @@ static void test_event_c(TestEventData *data, b.has_enum1 = false; d_b =qdict_new (); -qdict_put (d_b,"integer" ,qint_from_int (2 )); -qdict_put (d_b,"string" ,qstring_from_str ("test1" )); +qdict_put_int (d_b,"integer" ,2 ); +qdict_put_str (d_b,"string" ,"test1" ); d_data =qdict_new (); -qdict_put (d_data,"a" ,qint_from_int (1 )); +qdict_put_int (d_data,"a" ,1 );qdict_put (d_data,"b" , d_b); -qdict_put (d_data,"c" ,qstring_from_str ("test2" )); +qdict_put_str (d_data,"c" ,"test2" ); d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_C" )); +qdict_put_str (d,"event" ,"EVENT_C" );qdict_put (d,"data" , d_data);qapi_event_send_event_c (true,1 , true, &b,"test2" , &error_abort);
@@ -213,22 +213,22 @@ static void test_event_d(TestEventData *data, a.enum2 =ENUM_ONE_VALUE2 ; d_struct1 =qdict_new (); -qdict_put (d_struct1,"integer" ,qint_from_int (2 )); -qdict_put (d_struct1,"string" ,qstring_from_str ("test1" )); -qdict_put (d_struct1,"enum1" ,qstring_from_str ("value1" )); +qdict_put_int (d_struct1,"integer" ,2 ); +qdict_put_str (d_struct1,"string" ,"test1" ); +qdict_put_str (d_struct1,"enum1" ,"value1" ); d_a =qdict_new ();qdict_put (d_a,"struct1" , d_struct1); -qdict_put (d_a,"string" ,qstring_from_str ("test2" )); -qdict_put (d_a,"enum2" ,qstring_from_str ("value2" )); +qdict_put_str (d_a,"string" ,"test2" ); +qdict_put_str (d_a,"enum2" ,"value2" ); d_data =qdict_new ();qdict_put (d_data,"a" , d_a); -qdict_put (d_data,"b" ,qstring_from_str ("test3" )); -qdict_put (d_data,"enum3" ,qstring_from_str ("value3" )); +qdict_put_str (d_data,"b" ,"test3" ); +qdict_put_str (d_data,"enum3" ,"value3" ); d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_D" )); +qdict_put_str (d,"event" ,"EVENT_D" );qdict_put (d,"data" , d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3,
tests/test-qobject-output-visitor.c +3 -3
@@ -343,9 +343,9 @@ static void test_visitor_out_any(TestOutputVisitorData *data,visitor_reset (data); qdict =qdict_new (); -qdict_put (qdict,"integer" ,qint_from_int (-42 )); -qdict_put (qdict,"boolean" ,qbool_from_bool (true)); -qdict_put (qdict,"string" ,qstring_from_str ("foo" )); +qdict_put_int (qdict,"integer" ,-42 ); +qdict_put_bool (qdict,"boolean" , true); +qdict_put_str (qdict,"string" ,"foo" ); qobj =QOBJECT (qdict);visit_type_any (data->ov,NULL , &qobj, &error_abort);qobject_decref (qobj);
util/qemu-option.c +1 -1
@@ -1060,7 +1060,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict) qdict =qdict_new (); }if (opts->id) { -qdict_put (qdict,"id" ,qstring_from_str (opts->id)); +qdict_put_str (qdict,"id" , opts->id); } QTAILQ_FOREACH(opt, &opts->head, next) { val =QOBJECT (qstring_from_str (opt->str));
Signature · 7 lines
2.9.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v5 8/10 QemuOpts: Simplify qemu_opts_to_qdict()
In reply to Eric BlakeNoticed while investigating Coccinelle cleanups. There is no need for a temporary variable when we can use the new macro to do the same thing with less typing.
---
v5: add R-b
v4: new patch
--- util/qemu-option.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
util/qemu-option.c +1 -3
@@ -1054,7 +1054,6 @@ void qemu_opts_absorb_qdict(QemuOpts *opts, QDict *qdict, Error **errp)QDict *qemu_opts_to_qdict (QemuOpts *opts,QDict *qdict) {QemuOpt *opt; -QObject *val;if (!qdict) { qdict =qdict_new ();
@@ -1063,8 +1062,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict)qdict_put_str (qdict,"id" , opts->id); } QTAILQ_FOREACH(opt, &opts->head, next) { - val =QOBJECT (qstring_from_str (opt->str)); -qdict_put_obj (qdict, opt->name, val); +qdict_put_str (qdict, opt->name, opt->str); }return qdict; }
Signature · 1 line
2.9.3
PATCH v5 7/10 block: Simplify bdrv_append_temp_snapshot() logic
In reply to Eric BlakeNoticed while checking Coccinelle results. Naming a label 'out:' when it is only used on error paths is weird. Also, we had some dead stores to 'ret'. Meanwhile we know that snapshot_options is NULL on success and that QDECREF(NULL) is safe. So merge the two exit paths into one by careful control over bs_snapshot.
---
v5: add R-b
v4: fix -O2 compilation bug, kill dead 'ret'
v3: split out from bigger v2 patch
--- block.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-)
block.c +8 -11
@@ -2195,7 +2195,7 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs,char *tmp_filename =g_malloc0 (PATH_MAX +1 );int64_t total_size;QemuOpts *opts =NULL ; -BlockDriverState *bs_snapshot; +BlockDriverState *bs_snapshot =NULL ;Error *local_err =NULL ;int ret;
@@ -2235,28 +2235,25 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, bs_snapshot =bdrv_open (NULL ,NULL , snapshot_options, flags, errp); snapshot_options =NULL ;if (!bs_snapshot) { - ret = -EINVAL ; goto out; } -/* bdrv_append() consumes a strong reference to bs_snapshot (i.e. it will -* call bdrv_unref() on it), so in order to be able to return one, we have -* to increase bs_snapshot's refcount here */ +/* bdrv_append() consumes a strong reference to bs_snapshot +* (i.e. it will call bdrv_unref() on it) even on error, so in +* order to be able to return one, we have to increase +* bs_snapshot's refcount here */ bdrv_ref (bs_snapshot);bdrv_append (bs_snapshot, bs, &local_err);if (local_err) {error_propagate (errp, local_err); - ret = -EINVAL ; + bs_snapshot =NULL ; goto out; } +out: +QDECREF (snapshot_options);g_free (tmp_filename);return bs_snapshot; - -out: -QDECREF (snapshot_options); -g_free (tmp_filename); -return NULL ; }/*
Signature · 1 line
2.9.3
PATCH v5 9/10 fdc-test: Avoid deprecated 'change' command
In reply to Eric BlakeUse the preferred blockdev-change-medium command instead.
Also, use of 'device' is deprecated; adding an explicit id on the command line lets us use 'id' for both blockdev-change-medium and eject.
---
v5: add R-b
v4: use 'id' rather than 'device' [thanks to John and Kevin]
v3: update commit message to point out that we are still using deprecated 'device'
--- tests/fdc-test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tests/fdc-test.c +4 -4
@@ -298,8 +298,8 @@ static void test_media_insert(void)/* Insert media in drive. DSKCHK should not be reset until a step pulse * is sent. */ -qmp_discard_response ("{'execute':'change', 'arguments':{" -" 'device':'floppy0', 'target': %s, 'arg': 'raw' }}" , +qmp_discard_response ("{'execute':'blockdev-change-medium', 'arguments':{" +" 'id':'floppy0', 'filename': %s, 'format': 'raw' }}" , test_image); dir =inb (FLOPPY_BASE + reg_dir);
@@ -330,7 +330,7 @@ static void test_media_change(void)/* Eject the floppy and check that DSKCHG is set. Reading it out doesn't * reset the bit. */ qmp_discard_response ("{'execute':'eject', 'arguments':{" -" 'device':'floppy0' }}" ); +" 'id':'floppy0' }}" ); dir =inb (FLOPPY_BASE + reg_dir);assert_bit_set (dir,DSKCHG );
@@ -564,7 +564,7 @@ int main(int argc, char **argv)/* Run the tests */ g_test_init (&argc, &argv,NULL ); -qtest_start (NULL ); +qtest_start ("-device floppy,id=floppy0" );qtest_irq_intercept_in (global_qtest,"ioapic" );qtest_add_func ("/fdc/cmos" , test_cmos);qtest_add_func ("/fdc/no_media_on_start" , test_no_media_on_start);
Signature · 1 line
2.9.3
PATCH v5 10/10 test-qga: Actually test 0xff sync bytes
In reply to Eric BlakeCommit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending 0xff to QGA to force the parser to reset. But this aspect of the test has never actually done anything: the qmp_fd() call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the 0xff byte from the string sent to QGA, thus never resetting the QGA parser.
An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
But fixing qmp_fd() to actually send 0xff over the wire is not all we have to do - the actual QMP parser loudly complains that 0xff is not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check 0xff behavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.
Ideally, we'd fix the QGA JSON parser to silently ignore 0xff rather than sending an error message back, at which point we could enhance this test for 'guest-sync' as well as for 'guest-sync-delimited'. But for the sake of this patch, our testing of 'guest-sync' is no worse than it was pre-patch, because we have never been sending 0xff over the wire in the first place.
---
v5: add R-b
v4: no change
v3: use inline \xff byte rather than %c, add comment
--- tests/libqtest.c | 8 ++++++++ tests/test-qga.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)
tests/libqtest.c +8 -0
@@ -446,6 +446,14 @@ void qmp_fd_sendv(int fd, const char *fmt, va_list ap)va_list ap_copy;QObject *qobj; +/* qobject_from_jsonv() silently eats leading 0xff as invalid +* JSON, but we want to test sending them over the wire to force +* resyncs */ +if (*fmt =='\377' ) { +socket_send (fd, fmt,1 ); + fmt++; + } +/* Going through qobject ensures we escape strings properly. * This seemingly unnecessary copy is required in case va_list * is an array type.
tests/test-qga.c +27 -7
@@ -146,14 +146,23 @@ static void test_qga_sync_delimited(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync-delimited'," -" 'arguments': {'id': %u } }" ,0xff , r); + cmd =g_strdup_printf ("\xff{'execute': 'guest-sync-delimited'," +" 'arguments': {'id': %u } }" , r);qmp_fd_send (fixture->fd, cmd);g_free (cmd); - v =read (fixture->fd, &c,1 ); - g_assert_cmpint(v, ==, 1); - g_assert_cmpint(c, ==, 0xff); +/* +* Read and ignore garbage until resynchronized. +* +* TODO: The server shouldn't emit so much garbage (among other +* things, it loudly complains about the client's \xff being +* invalid JSON, even though it is a documented part of the +* handshake. +*/ +do { + v =read (fixture->fd, &c,1 ); + g_assert_cmpint(v, ==, 1); + }while (c !=0xff ); ret =qmp_fd_receive (fixture->fd);g_assert_nonnull (ret);
@@ -172,8 +181,19 @@ static void test_qga_sync(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync'," -" 'arguments': {'id': %u } }" ,0xff , r); +/* +* TODO guest-sync is inherently limited: we cannot distinguish +* failure caused by reacting to garbage on the wire prior to this +* command, from failure of this actual command. Clients are +* supposed to be able to send a raw '\xff' byte to at least +* re-synchronize the server's parser prior to this command, but +* we are not in a position to test that here because (at least +* for now) it causes the server to issue an error message about +* invalid JSON. Testing of '\xff' handling is done in +* guest-sync-delimited instead. +*/ + cmd =g_strdup_printf ("{'execute': 'guest-sync'," +" 'arguments': {'id': %u } }" , r); ret =qmp_fd (fixture->fd, cmd);g_free (cmd);
Signature · 1 line
2.9.3
PATCH v5 6/10 qobject: Use simpler QDict/QList scalar insertion macros
In reply to Eric BlakeWe now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \
--macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in monitor.c.
---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
v4: no change
v3: new patch
--- block.c | 45 +++++------- block/blkdebug.c | 6 +- block/blkverify.c | 6 +- block/curl.c | 2 +- block/file-posix.c | 8 +-- block/file-win32.c | 4 +- block/nbd.c | 41 ++++++----- block/nfs.c | 43 +++++------- block/null.c | 2 +- block/qcow2.c | 4 +- block/quorum.c | 8 +-- block/rbd.c | 16 ++--- block/snapshot.c | 2 +- block/ssh.c | 16 ++--- block/vvfat.c | 10 +-- block/vxhs.c | 6 +- blockdev.c | 30 ++++---- hw/block/xen_disk.c | 2 +- hw/usb/xen-usb.c | 12 ++-- monitor.c | 23 +++---- qapi/qmp-event.c | 2 +- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qobject/qdict.c | 2 +- target/s390x/cpu_models.c | 4 +- tests/check-qdict.c | 134 ++++++++++++++++++------------------ tests/check-qlist.c | 4 +- tests/device-introspect-test.c | 4 +- tests/test-qemu-opts.c | 4 +- tests/test-qmp-commands.c | 24 +++---- tests/test-qmp-event.c | 30 ++++---- tests/test-qobject-output-visitor.c | 6 +- util/qemu-option.c | 2 +- 34 files changed, 244 insertions(+), 268 deletions(-)
block.c +19 -26
@@ -974,16 +974,14 @@ static void update_flags_from_options(int *flags, QemuOpts *opts)static void update_options_from_flags (QDict *options,int flags) {if (!qdict_haskey (options,BDRV_OPT_CACHE_DIRECT )) { -qdict_put (options,BDRV_OPT_CACHE_DIRECT , -qbool_from_bool (flags &BDRV_O_NOCACHE )); +qdict_put_bool (options,BDRV_OPT_CACHE_DIRECT , flags &BDRV_O_NOCACHE ); }if (!qdict_haskey (options,BDRV_OPT_CACHE_NO_FLUSH )) { -qdict_put (options,BDRV_OPT_CACHE_NO_FLUSH , -qbool_from_bool (flags &BDRV_O_NO_FLUSH )); +qdict_put_bool (options,BDRV_OPT_CACHE_NO_FLUSH , + flags &BDRV_O_NO_FLUSH ); }if (!qdict_haskey (options,BDRV_OPT_READ_ONLY )) { -qdict_put (options,BDRV_OPT_READ_ONLY , -qbool_from_bool (!(flags &BDRV_O_RDWR ))); +qdict_put_bool (options,BDRV_OPT_READ_ONLY , !(flags &BDRV_O_RDWR )); } }
@@ -1399,7 +1397,7 @@ static int bdrv_fill_options(QDict **options, const char *filename,/* Fetch the file name from the options QDict if necessary */ if (protocol && filename) {if (!qdict_haskey (*options,"filename" )) { -qdict_put (*options,"filename" ,qstring_from_str (filename)); +qdict_put_str (*options,"filename" , filename); parse_filename = true; }else { error_setg(errp, "Can't specify 'file' and 'filename' options at "
@@ -1420,7 +1418,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, } drvname = drv->format_name; -qdict_put (*options,"driver" ,qstring_from_str (drvname)); +qdict_put_str (*options,"driver" , drvname); }else {error_setg (errp,"Must specify either driver or file" );return -EINVAL ;
@@ -2075,7 +2073,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, }if (bs->backing_format[0 ] !='\0' && !qdict_haskey (options,"driver" )) { -qdict_put (options,"driver" ,qstring_from_str (bs->backing_format)); +qdict_put_str (options,"driver" , bs->backing_format); } backing_hd = bdrv_open_inherit(*backing_filename ? backing_filename : NULL,
@@ -2230,12 +2228,9 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, }/* Prepare options QDict for the temporary file */ -qdict_put (snapshot_options,"file.driver" , -qstring_from_str ("file" )); -qdict_put (snapshot_options,"file.filename" , -qstring_from_str (tmp_filename)); -qdict_put (snapshot_options,"driver" , -qstring_from_str ("qcow2" )); +qdict_put_str (snapshot_options,"file.driver" ,"file" ); +qdict_put_str (snapshot_options,"file.filename" , tmp_filename); +qdict_put_str (snapshot_options,"driver" ,"qcow2" ); bs_snapshot =bdrv_open (NULL ,NULL , snapshot_options, flags, errp); snapshot_options =NULL ;
@@ -2410,8 +2405,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, goto fail; } -qdict_put (options,"file" , -qstring_from_str (bdrv_get_node_name (file_bs))); +qdict_put_str (options,"file" ,bdrv_get_node_name (file_bs)); } }
@@ -2433,8 +2427,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,* sure to update both bs->options (which has the full effective * options for bs) and options (which has file.* already removed). */ -qdict_put (bs->options,"driver" ,qstring_from_str (drv->format_name)); -qdict_put (options,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (bs->options,"driver" , drv->format_name); +qdict_put_str (options,"driver" , drv->format_name); }else if (!drv) {error_setg (errp,"Must specify either driver or file" ); goto fail;
@@ -2810,12 +2804,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue,* that they are checked at the end of this function. */ value =qemu_opt_get (opts,"node-name" );if (value) { -qdict_put (reopen_state->options,"node-name" ,qstring_from_str (value)); +qdict_put_str (reopen_state->options,"node-name" , value); } value =qemu_opt_get (opts,"driver" );if (value) { -qdict_put (reopen_state->options,"driver" ,qstring_from_str (value)); +qdict_put_str (reopen_state->options,"driver" , value); }/* If we are to stay read-only, do not allow permission change
@@ -4302,8 +4296,7 @@ void bdrv_img_create(const char *filename, const char *fmt,if (backing_fmt) { backing_options =qdict_new (); -qdict_put (backing_options,"driver" , -qstring_from_str (backing_fmt)); +qdict_put_str (backing_options,"driver" , backing_fmt); } bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
@@ -4708,7 +4701,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ if (bs->file->bs->full_open_options) { -qdict_put (opts,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (opts,"driver" , drv->format_name);QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"file" , bs->file->bs->full_open_options);
@@ -4726,7 +4719,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) opts =qdict_new ();append_open_options (opts, bs); -qdict_put (opts,"driver" ,qstring_from_str (drv->format_name)); +qdict_put_str (opts,"driver" , drv->format_name);if (bs->exact_filename[0 ]) {/* This may not work for all block protocol drivers (some may
@@ -4736,7 +4729,7 @@ void bdrv_refresh_filename(BlockDriverState *bs)* needs some special format of the options QDict, it needs to * implement the driver-specific bdrv_refresh_filename() function. */ -qdict_put (opts,"filename" ,qstring_from_str (bs->exact_filename)); +qdict_put_str (opts,"filename" , bs->exact_filename); } bs->full_open_options = opts;
block/blkdebug.c +3 -3
@@ -301,7 +301,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,if (!strstart (filename,"blkdebug:" , &filename)) {/* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename);return ; }
@@ -320,7 +320,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options,/* TODO Allow multi-level nesting and set file.filename here */ filename = c +1 ; -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename); }static QemuOptsList runtime_opts = {
@@ -695,7 +695,7 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("blkdebug" )); +qdict_put_str (opts,"driver" ,"blkdebug" );QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"image" , bs->file->bs->full_open_options);
block/blkverify.c +3 -3
@@ -67,7 +67,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,if (!strstart (filename,"blkverify:" , &filename)) {/* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename);return ; }
@@ -84,7 +84,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options,/* TODO Allow multi-level nesting and set file.filename here */ filename = c +1 ; -qdict_put (options,"x-image" ,qstring_from_str (filename)); +qdict_put_str (options,"x-image" , filename); }static QemuOptsList runtime_opts = {
@@ -291,7 +291,7 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) && s->test_file->bs->full_open_options) {QDict *opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("blkverify" )); +qdict_put_str (opts,"driver" ,"blkverify" );QINCREF (bs->file->bs->full_open_options);qdict_put (opts,"raw" , bs->file->bs->full_open_options);
block/curl.c +1 -1
@@ -548,7 +548,7 @@ static void curl_clean_state(CURLState *s)static void curl_parse_filename (const char *filename,QDict *options,Error **errp) { -qdict_put (options,CURL_BLOCK_OPT_URL ,qstring_from_str (filename)); +qdict_put_str (options,CURL_BLOCK_OPT_URL , filename); }static void curl_detach_aio_context (BlockDriverState *bs)
block/file-posix.c +4 -4
@@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static QemuOptsList raw_runtime_opts = {
@@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static bool hdev_is_sg (BlockDriverState *bs)
@@ -2239,7 +2239,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, goto hdev_open_Mac_error; } -qdict_put (options,"filename" ,qstring_from_str (bsd_path)); +qdict_put_str (options,"filename" , bsd_path); hdev_open_Mac_error:g_free (mediaType);
@@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_cdrom:" , &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); }#endif
block/file-win32.c +2 -2
@@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options,* function call can be ignored. */ strstart (filename,"file:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); }static QemuOptsList raw_runtime_opts = {
@@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options,/* The prefix is optional, just as for "file". */ strstart (filename,"host_device:" , &filename); -qdict_put (options,"filename" ,qstring_from_str (filename)); +qdict_put_str (options,"filename" , filename); } static int hdev_open(BlockDriverState *bs, QDict *options, int flags,
block/nbd.c +20 -21
101 lines not on this page · raw message
block/nfs.c +17 -26
84 lines not on this page · raw message
block/null.c +1 -1
@@ -232,7 +232,7 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts) bs->drv->format_name); } -qdict_put (opts,"driver" ,qstring_from_str (bs->drv->format_name)); +qdict_put_str (opts,"driver" , bs->drv->format_name); bs->full_open_options = opts; }
block/qcow2.c +2 -2
@@ -2265,7 +2265,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,* table) */ options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str ("qcow2" )); +qdict_put_str (options,"driver" ,"qcow2" ); blk =blk_new_open (filename,NULL , options,BDRV_O_RDWR |BDRV_O_RESIZE |BDRV_O_NO_FLUSH , &local_err);
@@ -2327,7 +2327,7 @@ static int qcow2_create2(const char *filename, int64_t total_size,/* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */ options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str ("qcow2" )); +qdict_put_str (options,"driver" ,"qcow2" ); blk =blk_new_open (filename,NULL , options,BDRV_O_RDWR |BDRV_O_NO_BACKING , &local_err);if (blk ==NULL ) {
block/quorum.c +4 -4
@@ -1100,10 +1100,10 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) } opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str ("quorum" )); -qdict_put (opts,QUORUM_OPT_VOTE_THRESHOLD ,qint_from_int (s->threshold)); -qdict_put (opts,QUORUM_OPT_BLKVERIFY ,qbool_from_bool (s->is_blkverify)); -qdict_put (opts,QUORUM_OPT_REWRITE ,qbool_from_bool (s->rewrite_corrupted)); +qdict_put_str (opts,"driver" ,"quorum" ); +qdict_put_int (opts,QUORUM_OPT_VOTE_THRESHOLD , s->threshold); +qdict_put_bool (opts,QUORUM_OPT_BLKVERIFY , s->is_blkverify); +qdict_put_bool (opts,QUORUM_OPT_REWRITE , s->rewrite_corrupted);qdict_put (opts,"children" , children); bs->full_open_options = opts;
block/rbd.c +8 -8
@@ -154,20 +154,20 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, goto done; }qemu_rbd_unescape (found_str); -qdict_put (options,"pool" ,qstring_from_str (found_str)); +qdict_put_str (options,"pool" , found_str);if (strchr (p,'@' )) { found_str =qemu_rbd_next_tok (p,'@' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"image" ,qstring_from_str (found_str)); +qdict_put_str (options,"image" , found_str); found_str =qemu_rbd_next_tok (p,':' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"snapshot" ,qstring_from_str (found_str)); +qdict_put_str (options,"snapshot" , found_str); }else { found_str =qemu_rbd_next_tok (p,':' , &p);qemu_rbd_unescape (found_str); -qdict_put (options,"image" ,qstring_from_str (found_str)); +qdict_put_str (options,"image" , found_str); }if (!p) { goto done;
@@ -189,9 +189,9 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,qemu_rbd_unescape (value);if (!strcmp (name,"conf" )) { -qdict_put (options,"conf" ,qstring_from_str (value)); +qdict_put_str (options,"conf" , value); }else if (!strcmp (name,"id" )) { -qdict_put (options,"user" ,qstring_from_str (value)); +qdict_put_str (options,"user" , value); }else {/* * We pass these internally to qemu_rbd_set_keypairs(), so
@@ -204,8 +204,8 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options,if (!keypairs) { keypairs =qlist_new (); } -qlist_append (keypairs,qstring_from_str (name)); -qlist_append (keypairs,qstring_from_str (value)); +qlist_append_str (keypairs, name); +qlist_append_str (keypairs, value); } }
block/snapshot.c +1 -1
@@ -200,7 +200,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs,qdict_extract_subqdict (options, &file_options,"file." );QDECREF (file_options); -qdict_put (options,"file" ,qstring_from_str (bdrv_get_node_name (file))); +qdict_put_str (options,"file" ,bdrv_get_node_name (file)); drv->bdrv_close (bs);bdrv_unref_child (bs, bs->file);
block/ssh.c +7 -9
@@ -227,24 +227,23 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) }if (uri->user &&strcmp (uri->user,"" ) !=0 ) { -qdict_put (options,"user" ,qstring_from_str (uri->user)); +qdict_put_str (options,"user" , uri->user); } -qdict_put (options,"server.host" ,qstring_from_str (uri->server)); +qdict_put_str (options,"server.host" , uri->server); port_str =g_strdup_printf ("%d" , uri->port ?:22 ); -qdict_put (options,"server.port" ,qstring_from_str (port_str)); +qdict_put_str (options,"server.port" , port_str);g_free (port_str); -qdict_put (options,"path" ,qstring_from_str (uri->path)); +qdict_put_str (options,"path" , uri->path);/* Pick out any query parameters that we understand, and ignore * the rest. */ for (i =0 ; i < qp->n; ++i) {if (strcmp (qp->p[i].name,"host_key_check" ) ==0 ) { -qdict_put (options,"host_key_check" , -qstring_from_str (qp->p[i].value)); +qdict_put_str (options,"host_key_check" , qp->p[i].value); } }
@@ -574,9 +573,8 @@ static bool ssh_process_legacy_socket_options(QDict *output_opts, }if (host) { -qdict_put (output_opts,"server.host" ,qstring_from_str (host)); -qdict_put (output_opts,"server.port" , -qstring_from_str (port ?:stringify (22 ))); +qdict_put_str (output_opts,"server.host" , host); +qdict_put_str (output_opts,"server.port" , port ?:stringify (22 )); }return true;
block/vvfat.c +5 -5
@@ -1057,10 +1057,10 @@ static void vvfat_parse_filename(const char *filename, QDict *options, }/* Fill in the options QDict */ -qdict_put (options,"dir" ,qstring_from_str (filename)); -qdict_put (options,"fat-type" ,qint_from_int (fat_type)); -qdict_put (options,"floppy" ,qbool_from_bool (floppy)); -qdict_put (options,"rw" ,qbool_from_bool (rw)); +qdict_put_str (options,"dir" , filename); +qdict_put_int (options,"fat-type" , fat_type); +qdict_put_bool (options,"floppy" , floppy); +qdict_put_bool (options,"rw" , rw); } static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,
@@ -3051,7 +3051,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp) } options =qdict_new (); -qdict_put (options,"write-target.driver" ,qstring_from_str ("qcow" )); +qdict_put_str (options,"write-target.driver" ,"qcow" ); s->qcow =bdrv_open_child (s->qcow_filename, options,"write-target" , bs, &child_vvfat_qcow, false, errp);QDECREF (options);
block/vxhs.c +3 -3
@@ -182,15 +182,15 @@ static int vxhs_parse_uri(const char *filename, QDict *options)return -EINVAL ; } -qdict_put (options,VXHS_OPT_SERVER ".host" ,qstring_from_str (uri->server)); +qdict_put_str (options,VXHS_OPT_SERVER ".host" , uri->server);if (uri->port) { port =g_strdup_printf ("%d" , uri->port); -qdict_put (options,VXHS_OPT_SERVER ".port" ,qstring_from_str (port)); +qdict_put_str (options,VXHS_OPT_SERVER ".port" , port);g_free (port); } -qdict_put (options,"vdisk-id" ,qstring_from_str (uri->path)); +qdict_put_str (options,"vdisk-id" , uri->path);trace_vxhs_parse_uri_hostinfo (uri->server, uri->port);uri_free (uri);
blockdev.c +13 -17
@@ -527,7 +527,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,error_setg (errp,"Cannot specify both 'driver' and 'format'" ); goto early_err; } -qdict_put (bs_opts,"driver" ,qstring_from_str (buf)); +qdict_put_str (bs_opts,"driver" , buf); } on_write_error =BLOCKDEV_ON_ERROR_ENOSPC ;
@@ -903,10 +903,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) copy_on_read = false; } -qdict_put (bs_opts,BDRV_OPT_READ_ONLY , -qstring_from_str (read_only ?"on" :"off" )); -qdict_put (bs_opts,"copy-on-read" , -qstring_from_str (copy_on_read ?"on" :"off" )); +qdict_put_str (bs_opts,BDRV_OPT_READ_ONLY , read_only ?"on" :"off" ); +qdict_put_str (bs_opts,"copy-on-read" , copy_on_read ?"on" :"off" );/* Controller type */ value =qemu_opt_get (legacy_opts,"if" );
@@ -1030,7 +1028,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) new_id =g_strdup_printf ("%s%s%i" , if_name[type], mediastr, unit_id); } -qdict_put (bs_opts,"id" ,qstring_from_str (new_id)); +qdict_put_str (bs_opts,"id" , new_id);g_free (new_id); }
@@ -1067,7 +1065,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)error_report ("werror is not supported by this bus type" ); goto fail; } -qdict_put (bs_opts,"werror" ,qstring_from_str (werror)); +qdict_put_str (bs_opts,"werror" , werror); } rerror =qemu_opt_get (legacy_opts,"rerror" );
@@ -1077,7 +1075,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)error_report ("rerror is not supported by this bus type" ); goto fail; } -qdict_put (bs_opts,"rerror" ,qstring_from_str (rerror)); +qdict_put_str (bs_opts,"rerror" , rerror); }/* Actual block device init: Functionality shared with blockdev-add */
@@ -1737,10 +1735,9 @@ static void external_snapshot_prepare(BlkActionState *common, options =qdict_new ();if (s->has_snapshot_node_name) { -qdict_put (options,"node-name" , -qstring_from_str (snapshot_node_name)); +qdict_put_str (options,"node-name" , snapshot_node_name); } -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); flags |=BDRV_O_NO_BACKING ; }
@@ -2579,11 +2576,10 @@ void qmp_blockdev_change_medium(bool has_device, const char *device, options =qdict_new (); detect_zeroes =blk_get_detect_zeroes_from_root_state (blk); -qdict_put (options,"detect-zeroes" , -qstring_from_str (detect_zeroes ?"on" :"off" )); +qdict_put_str (options,"detect-zeroes" , detect_zeroes ?"on" :"off" );if (has_format) { -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); } medium_bs =bdrv_open (filename,NULL , options, bdrv_flags, errp);
@@ -3251,7 +3247,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn,if (backup->format) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (backup->format)); +qdict_put_str (options,"driver" , backup->format); } target_bs =bdrv_open (backup->target,NULL , options, flags, errp);
@@ -3555,10 +3551,10 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) options =qdict_new ();if (arg->has_node_name) { -qdict_put (options,"node-name" ,qstring_from_str (arg->node_name)); +qdict_put_str (options,"node-name" , arg->node_name); }if (format) { -qdict_put (options,"driver" ,qstring_from_str (format)); +qdict_put_str (options,"driver" , format); }/* Mirroring takes care of copy-on-write using the source's backing
hw/block/xen_disk.c +1 -1
@@ -1082,7 +1082,7 @@ static int blk_connect(struct XenDevice *xendev)if (strcmp (blkdev->fileproto,"<unset>" )) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (blkdev->fileproto)); +qdict_put_str (options,"driver" , blkdev->fileproto); }/* setup via xenbus -> create new block driver instance */
hw/usb/xen-usb.c +6 -6
@@ -746,16 +746,16 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port, portname++; qdict =qdict_new (); -qdict_put (qdict,"driver" ,qstring_from_str ("usb-host" )); +qdict_put_str (qdict,"driver" ,"usb-host" ); tmp =g_strdup_printf ("%s.0" , usbif->xendev.qdev.id); -qdict_put (qdict,"bus" ,qstring_from_str (tmp)); +qdict_put_str (qdict,"bus" , tmp);g_free (tmp); tmp =g_strdup_printf ("%s-%u" , usbif->xendev.qdev.id, port); -qdict_put (qdict,"id" ,qstring_from_str (tmp)); +qdict_put_str (qdict,"id" , tmp);g_free (tmp); -qdict_put (qdict,"port" ,qint_from_int (port)); -qdict_put (qdict,"hostbus" ,qint_from_int (atoi (busid))); -qdict_put (qdict,"hostport" ,qstring_from_str (portname)); +qdict_put_int (qdict,"port" , port); +qdict_put_int (qdict,"hostbus" ,atoi (busid)); +qdict_put_str (qdict,"hostport" , portname); opts =qemu_opts_from_qdict (qemu_find_opts ("device" ), qdict, &local_err);if (local_err) { goto err;
monitor.c +11 -12
@@ -2777,7 +2777,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } goto fail; } -qdict_put (qdict, key,qstring_from_str (buf)); +qdict_put_str (qdict, key, buf); }break ;case 'O' :
@@ -2879,9 +2879,9 @@ static QDict *monitor_parse_arguments(Monitor *mon, size =-1 ; } } -qdict_put (qdict,"count" ,qint_from_int (count)); -qdict_put (qdict,"format" ,qint_from_int (format)); -qdict_put (qdict,"size" ,qint_from_int (size)); +qdict_put_int (qdict,"count" , count); +qdict_put_int (qdict,"format" , format); +qdict_put_int (qdict,"size" , size); }break ;case 'i' :
@@ -2924,7 +2924,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } val <<=20 ; } -qdict_put (qdict, key,qint_from_int (val)); +qdict_put_int (qdict, key, val); }break ;case 'o' :
@@ -2947,7 +2947,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,monitor_printf (mon,"invalid size\n" ); goto fail; } -qdict_put (qdict, key,qint_from_int (val)); +qdict_put_int (qdict, key, val); p = end; }break ;
@@ -3003,7 +3003,7 @@ static QDict *monitor_parse_arguments(Monitor *mon,monitor_printf (mon,"Expected 'on' or 'off'\n" ); goto fail; } -qdict_put (qdict, key,qbool_from_bool (val)); +qdict_put_bool (qdict, key, val); }break ;case '-' :
@@ -3034,7 +3034,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, }else {/* has option */ p++; -qdict_put (qdict, key,qbool_from_bool (true)); +qdict_put_bool (qdict, key, true); } } }
@@ -3060,7 +3060,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, cmd->name); goto fail; } -qdict_put (qdict, key,qstring_from_str (p)); +qdict_put_str (qdict, key, p); p += len; }break ;
@@ -3839,9 +3839,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) {/* Provide a more useful error message */ qdict_del (qdict,"desc" ); -qdict_put (qdict,"desc" , -qstring_from_str ("Expecting capabilities negotiation" -" with 'qmp_capabilities'" )); +qdict_put_str (qdict,"desc" ,"Expecting capabilities negotiation" +" with 'qmp_capabilities'" ); } }
qapi/qmp-event.c +1 -1
@@ -51,7 +51,7 @@ static void timestamp_put(QDict *qdict)QDict *qmp_event_build_dict (const char *event_name) {QDict *dict =qdict_new (); -qdict_put (dict,"event" ,qstring_from_str (event_name)); +qdict_put_str (dict,"event" , event_name);timestamp_put (dict);return dict; }
qemu-img.c +3 -3
@@ -313,7 +313,7 @@ static BlockBackend *img_open_file(const char *filename,if (fmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (fmt)); +qdict_put_str (options,"driver" , fmt); } blk =blk_new_open (filename,NULL , options, flags, &local_err);
@@ -3158,7 +3158,7 @@ static int img_rebase(int argc, char **argv)if (bs->backing_format[0 ] !='\0' ) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (bs->backing_format)); +qdict_put_str (options,"driver" , bs->backing_format); }bdrv_get_backing_filename (bs, backing_name,sizeof (backing_name));
@@ -3175,7 +3175,7 @@ static int img_rebase(int argc, char **argv)if (out_baseimg[0 ]) {if (out_basefmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (out_basefmt)); +qdict_put_str (options,"driver" , out_basefmt); }else { options =NULL ; }
qemu-io.c +1 -1
@@ -601,7 +601,7 @@ int main(int argc, char **argv) }else {if (format) { opts =qdict_new (); -qdict_put (opts,"driver" ,qstring_from_str (format)); +qdict_put_str (opts,"driver" , format); }if (openfile (argv[optind], flags, writethrough, opts)) {exit (1 );
qemu-nbd.c +1 -1
@@ -959,7 +959,7 @@ int main(int argc, char **argv) }else {if (fmt) { options =qdict_new (); -qdict_put (options,"driver" ,qstring_from_str (fmt)); +qdict_put_str (options,"driver" , fmt); } blk =blk_new_open (srcpath,NULL , options, flags, &local_err); }
qobject/qdict.c +1 -1
@@ -463,7 +463,7 @@ void qdict_set_default_str(QDict *dst, const char *key, const char *val)return ; } -qdict_put (dst, key,qstring_from_str (val)); +qdict_put_str (dst, key, val); } static void qdict_flatten_qdict(QDict *qdict, QDict *target,
target/s390x/cpu_models.c +2 -2
@@ -376,12 +376,12 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info,static void qdict_add_disabled_feat (const char *name,void *opaque) { -qdict_put (opaque, name,qbool_from_bool (false)); +qdict_put_bool (opaque, name, false); }static void qdict_add_enabled_feat (const char *name,void *opaque) { -qdict_put (opaque, name,qbool_from_bool (true)); +qdict_put_bool (opaque, name, true); }/* convert S390CPUDef into a static CpuModelInfo */
tests/check-qdict.c +67 -67
302 lines not on this page · raw message
tests/check-qlist.c +2 -2
@@ -74,7 +74,7 @@ static void qlist_destroy_test(void) qlist =qlist_new ();for (i =0 ; i <42 ; i++) -qlist_append (qlist,qint_from_int (i)); +qlist_append_int (qlist, i);QDECREF (qlist); }
@@ -103,7 +103,7 @@ static void qlist_iter_test(void) qlist =qlist_new ();for (i =0 ; i < iter_max; i++) -qlist_append (qlist,qint_from_int (i)); +qlist_append_int (qlist, i); iter_called =0 ;qlist_iter (qlist, iter_func,NULL );
tests/device-introspect-test.c +2 -2
@@ -32,9 +32,9 @@ static QList *qom_list_types(const char *implements, bool abstract)QList *ret;QDict *args =qdict_new (); -qdict_put (args,"abstract" ,qbool_from_bool (abstract)); +qdict_put_bool (args,"abstract" , abstract);if (implements) { -qdict_put (args,"implements" ,qstring_from_str (implements)); +qdict_put_str (args,"implements" , implements); } resp =qmp ("{'execute': 'qom-list-types'," " 'arguments': %p }" , args);
tests/test-qemu-opts.c +2 -2
@@ -299,7 +299,7 @@ static void test_qemu_opt_get_size(void) dict =qdict_new ();g_assert (dict !=NULL ); -qdict_put (dict,"size1" ,qstring_from_str ("10" )); +qdict_put_str (dict,"size1" ,"10" );qemu_opts_absorb_qdict (opts, dict, &error_abort);g_assert (error_abort ==NULL );
@@ -309,7 +309,7 @@ static void test_qemu_opt_get_size(void)g_assert (opt ==10 );/* reset value */ -qdict_put (dict,"size1" ,qstring_from_str ("15" )); +qdict_put_str (dict,"size1" ,"15" );qemu_opts_absorb_qdict (opts, dict, &error_abort);g_assert (error_abort ==NULL );
tests/test-qmp-commands.c +12 -12
@@ -94,7 +94,7 @@ static void test_dispatch_cmd(void)QDict *req =qdict_new ();QObject *resp; -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); +qdict_put_str (req,"execute" ,"user_def_cmd" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -111,7 +111,7 @@ static void test_dispatch_cmd_failure(void)QDict *args =qdict_new ();QObject *resp; -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); +qdict_put_str (req,"execute" ,"user_def_cmd2" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -122,10 +122,10 @@ static void test_dispatch_cmd_failure(void)/* check that with extra arguments it throws an error */ req =qdict_new (); -qdict_put (args,"a" ,qint_from_int (66 )); +qdict_put_int (args,"a" ,66 );qdict_put (req,"arguments" , args); -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd" )); +qdict_put_str (req,"execute" ,"user_def_cmd" ); resp =qmp_dispatch (&qmp_commands,QOBJECT (req));assert (resp !=NULL );
@@ -164,14 +164,14 @@ static void test_dispatch_cmd_io(void)QDict *ret_dict_dict2, *ret_dict_dict2_userdef;QInt *ret3; -qdict_put (ud1a,"integer" ,qint_from_int (42 )); -qdict_put (ud1a,"string" ,qstring_from_str ("hello" )); -qdict_put (ud1b,"integer" ,qint_from_int (422 )); -qdict_put (ud1b,"string" ,qstring_from_str ("hello2" )); +qdict_put_int (ud1a,"integer" ,42 ); +qdict_put_str (ud1a,"string" ,"hello" ); +qdict_put_int (ud1b,"integer" ,422 ); +qdict_put_str (ud1b,"string" ,"hello2" );qdict_put (args,"ud1a" , ud1a);qdict_put (args,"ud1b" , ud1b);qdict_put (req,"arguments" , args); -qdict_put (req,"execute" ,qstring_from_str ("user_def_cmd2" )); +qdict_put_str (req,"execute" ,"user_def_cmd2" ); ret =qobject_to_qdict (test_qmp_dispatch (req));
@@ -190,9 +190,9 @@ static void test_dispatch_cmd_io(void)assert (!strcmp (qdict_get_str (ret_dict_dict2,"string" ),"blah4" ));QDECREF (ret); -qdict_put (args3,"a" ,qint_from_int (66 )); +qdict_put_int (args3,"a" ,66 );qdict_put (req,"arguments" , args3); -qdict_put (req,"execute" ,qstring_from_str ("guest-get-time" )); +qdict_put_str (req,"execute" ,"guest-get-time" ); ret3 =qobject_to_qint (test_qmp_dispatch (req));assert (qint_get_int (ret3) ==66 );
@@ -244,7 +244,7 @@ static void test_dealloc_partial(void)Visitor *v; ud2_dict =qdict_new (); -qdict_put (ud2_dict,"string0" ,qstring_from_str (text)); +qdict_put_str (ud2_dict,"string0" , text); v =qobject_input_visitor_new (QOBJECT (ud2_dict));visit_type_UserDefTwo (v,NULL , &ud2, &err);
tests/test-qmp-event.c +15 -15
@@ -153,7 +153,7 @@ static void test_event_a(TestEventData *data, {QDict *d; d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_A" )); +qdict_put_str (d,"event" ,"EVENT_A" );qapi_event_send_event_a (&error_abort); }
@@ -162,7 +162,7 @@ static void test_event_b(TestEventData *data, {QDict *d; d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_B" )); +qdict_put_str (d,"event" ,"EVENT_B" );qapi_event_send_event_b (&error_abort); }
@@ -177,16 +177,16 @@ static void test_event_c(TestEventData *data, b.has_enum1 = false; d_b =qdict_new (); -qdict_put (d_b,"integer" ,qint_from_int (2 )); -qdict_put (d_b,"string" ,qstring_from_str ("test1" )); +qdict_put_int (d_b,"integer" ,2 ); +qdict_put_str (d_b,"string" ,"test1" ); d_data =qdict_new (); -qdict_put (d_data,"a" ,qint_from_int (1 )); +qdict_put_int (d_data,"a" ,1 );qdict_put (d_data,"b" , d_b); -qdict_put (d_data,"c" ,qstring_from_str ("test2" )); +qdict_put_str (d_data,"c" ,"test2" ); d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_C" )); +qdict_put_str (d,"event" ,"EVENT_C" );qdict_put (d,"data" , d_data);qapi_event_send_event_c (true,1 , true, &b,"test2" , &error_abort);
@@ -213,22 +213,22 @@ static void test_event_d(TestEventData *data, a.enum2 =ENUM_ONE_VALUE2 ; d_struct1 =qdict_new (); -qdict_put (d_struct1,"integer" ,qint_from_int (2 )); -qdict_put (d_struct1,"string" ,qstring_from_str ("test1" )); -qdict_put (d_struct1,"enum1" ,qstring_from_str ("value1" )); +qdict_put_int (d_struct1,"integer" ,2 ); +qdict_put_str (d_struct1,"string" ,"test1" ); +qdict_put_str (d_struct1,"enum1" ,"value1" ); d_a =qdict_new ();qdict_put (d_a,"struct1" , d_struct1); -qdict_put (d_a,"string" ,qstring_from_str ("test2" )); -qdict_put (d_a,"enum2" ,qstring_from_str ("value2" )); +qdict_put_str (d_a,"string" ,"test2" ); +qdict_put_str (d_a,"enum2" ,"value2" ); d_data =qdict_new ();qdict_put (d_data,"a" , d_a); -qdict_put (d_data,"b" ,qstring_from_str ("test3" )); -qdict_put (d_data,"enum3" ,qstring_from_str ("value3" )); +qdict_put_str (d_data,"b" ,"test3" ); +qdict_put_str (d_data,"enum3" ,"value3" ); d = data->expect; -qdict_put (d,"event" ,qstring_from_str ("EVENT_D" )); +qdict_put_str (d,"event" ,"EVENT_D" );qdict_put (d,"data" , d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3,
tests/test-qobject-output-visitor.c +3 -3
@@ -343,9 +343,9 @@ static void test_visitor_out_any(TestOutputVisitorData *data,visitor_reset (data); qdict =qdict_new (); -qdict_put (qdict,"integer" ,qint_from_int (-42 )); -qdict_put (qdict,"boolean" ,qbool_from_bool (true)); -qdict_put (qdict,"string" ,qstring_from_str ("foo" )); +qdict_put_int (qdict,"integer" ,-42 ); +qdict_put_bool (qdict,"boolean" , true); +qdict_put_str (qdict,"string" ,"foo" ); qobj =QOBJECT (qdict);visit_type_any (data->ov,NULL , &qobj, &error_abort);qobject_decref (qobj);
util/qemu-option.c +1 -1
@@ -1060,7 +1060,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict) qdict =qdict_new (); }if (opts->id) { -qdict_put (qdict,"id" ,qstring_from_str (opts->id)); +qdict_put_str (qdict,"id" , opts->id); } QTAILQ_FOREACH(opt, &opts->head, next) { val =QOBJECT (qstring_from_str (opt->str));
Signature · 1 line
2.9.3
Markus Armbruster
Acked-by Richard W.M. Jones Reviewed-by Stefan Hajnoczi Reviewed-by Alberto Garcia Reviewed-by Philippe Mathieu-Daudé on v5 6/10Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
Quoted 3 lines · Eric Blake
We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Scratch the last sentence. Can do on commit.
Quoted 6 lines
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in
monitor.c.
Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
The block: part had
The tests and qobject parts had
Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
Quoted 2 lines
v4: no change
v3: new patch
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Markus Armbruster
Acked-by Richard W.M. Jones Reviewed-by Stefan Hajnoczi Reviewed-by Alberto Garcia Reviewed-by Philippe Mathieu-Daudé on v5 6/10Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
In reply to Eric BlakeQuoted 3 lines · Eric Blake
We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Scratch the last sentence. Can do on commit.
Quoted 6 lines
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in
monitor.c.
Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
The block: part had
The tests and qobject parts had
Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
Quoted 2 lines
v4: no change
v3: new patch
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
Quoted 28 lines · Markus Armbruster
Quoted 3 lines · Eric Blake
We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Scratch the last sentence. Can do on commit.
Quoted 6 lines
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in
monitor.c.Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
Quoted 7 lines
The tests and qobject parts had
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
Please keep my R-by, I have reviewed again.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
Quoted 31 lines · Stefan Hajnoczi
Quoted 30 lines · Markus Armbruster
Quoted 3 lines · Eric Blake
We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Scratch the last sentence. Can do on commit.
Quoted 6 lines
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in
monitor.c.Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>The tests and qobject parts had
Quoted 7 lines
Quoted 5 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
Please keep my R-by, I have reviewed again.
Gladly. Thanks!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
In reply to Stefan HajnocziQuoted 31 lines · Stefan Hajnoczi
Quoted 30 lines · Markus Armbruster
Quoted 3 lines · Eric Blake
We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. To make this patch smaller to review, a couple of subdirectories were done in earlier patches.
Scratch the last sentence. Can do on commit.
Quoted 6 lines
Patch created mechanically via:
spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-placethen touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in
monitor.c.Quoted 7 lines
Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>The tests and qobject parts had
Quoted 7 lines
Quoted 5 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
Please keep my R-by, I have reviewed again.
Gladly. Thanks!
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
In reply to Eric BlakeQuoting Eric Blake (2017-04-27 16:58:21)
Quoted 14 lines
Commit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending
0xffto QGA to force the parser to reset. But this aspect of the test has never actually done anything: theqmp_fd()call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the0xffbyte from the string sent to QGA, thus never resetting the QGA parser.An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
Quoted 11 lines
But fixing
qmp_fd()to actually send0xffover the wire is not all we have to do - the actual QMP parser loudly complains that0xffis not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check0xffbehavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.
The full re-sync sequence is actually to perform that process, check if the response matches the client-provided sync token, and then repeat the procedure if it doesn't (in the odd case that a previous client initiated a guest-sync-delimited sequence and never consumed the response). The current implementation only performs one iteration so it's not quite a full implementation of the documentation procedure.
For the immediate purpose of improving the handling to deal with the 0xFF-generated error the patch seems sound though, maybe just something worth noting in the commit msg or comments so that we might eventually test the full procedure.
In any case:
Quoted 99 lines
Ideally, we'd fix the QGA JSON parser to silently ignore
0xffrather than sending an error message back, at which point we could enhance this test for 'guest-sync' as well as for 'guest-sync-delimited'. But for the sake of this patch, our testing of 'guest-sync' is no worse than it was pre-patch, because we have never been sending0xffover the wire in the first place.Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: add R-b
v4: no change
v3: use inline \xff byte rather than %c, add comment--- tests/libqtest.c | 8 ++++++++ tests/test-qga.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)tests/libqtest.c +8
-0@@ -446,6 +446,14 @@ void qmp_fd_sendv(int fd, const char *fmt, va_list ap)va_list ap_copy;QObject *qobj; +/* qobject_from_jsonv() silently eats leading 0xff as invalid +* JSON, but we want to test sending them over the wire to force +* resyncs */ +if (*fmt =='\377' ) { +socket_send (fd, fmt,1 ); + fmt++; + } +/* Going through qobject ensures we escape strings properly. * This seemingly unnecessary copy is required in case va_list * is an array type. tests/test-qga.c +27
-7@@ -146,14 +146,23 @@ static void test_qga_sync_delimited(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync-delimited'," -" 'arguments': {'id': %u } }" ,0xff , r); + cmd =g_strdup_printf ("\xff{'execute': 'guest-sync-delimited'," +" 'arguments': {'id': %u } }" , r);qmp_fd_send (fixture->fd, cmd);g_free (cmd); - v =read (fixture->fd, &c,1 ); - g_assert_cmpint(v, ==, 1); - g_assert_cmpint(c, ==, 0xff); +/* +* Read and ignore garbage until resynchronized. +* +* TODO: The server shouldn't emit so much garbage (among other +* things, it loudly complains about the client's \xff being +* invalid JSON, even though it is a documented part of the +* handshake. +*/ +do { + v =read (fixture->fd, &c,1 ); + g_assert_cmpint(v, ==, 1); + }while (c !=0xff ); ret =qmp_fd_receive (fixture->fd);g_assert_nonnull (ret);@@ -172,8 +181,19 @@ static void test_qga_sync(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync'," -" 'arguments': {'id': %u } }" ,0xff , r); +/* +* TODO guest-sync is inherently limited: we cannot distinguish +* failure caused by reacting to garbage on the wire prior to this +* command, from failure of this actual command. Clients are +* supposed to be able to send a raw '\xff' byte to at least +* re-synchronize the server's parser prior to this command, but +* we are not in a position to test that here because (at least +* for now) it causes the server to issue an error message about +* invalid JSON. Testing of '\xff' handling is done in +* guest-sync-delimited instead. +*/ + cmd =g_strdup_printf ("{'execute': 'guest-sync'," +" 'arguments': {'id': %u } }" , r); ret =qmp_fd (fixture->fd, cmd);g_free (cmd);Signature · 1 line
2.9.3
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
Quoting Michael Roth (2017-05-02 11:46:36)
Quoted 27 lines
Quoting Eric Blake (2017-04-27 16:58:21)
Quoted 14 lines
Commit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending
0xffto QGA to force the parser to reset. But this aspect of the test has never actually done anything: theqmp_fd()call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the0xffbyte from the string sent to QGA, thus never resetting the QGA parser.An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
Quoted 11 lines
But fixing
qmp_fd()to actually send0xffover the wire is not all we have to do - the actual QMP parser loudly complains that0xffis not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check0xffbehavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.
Quoted 7 lines
The full re-sync sequence is actually to perform that process, check if the response matches the client-provided sync token, and then repeat the procedure if it doesn't (in the odd case that a previous client initiated a guest-sync-delimited sequence and never consumed the response). The current implementation only performs one iteration so it's not quite a full implementation of the documentation procedure.
Well, to be more accurate it's a full implementation of the documented procedure, it's just that the procedure isn't fully documented properly. I'll send a patch to address that.
Quoted 109 lines
For the immediate purpose of improving the handling to deal with the 0xFF-generated error the patch seems sound though, maybe just something worth noting in the commit msg or comments so that we might eventually test the full procedure.
In any case:
Reviewed-by Michael Roth <[email protected]>Quoted 99 lines
Ideally, we'd fix the QGA JSON parser to silently ignore
0xffrather than sending an error message back, at which point we could enhance this test for 'guest-sync' as well as for 'guest-sync-delimited'. But for the sake of this patch, our testing of 'guest-sync' is no worse than it was pre-patch, because we have never been sending0xffover the wire in the first place.Signed-off-by Eric Blake <[email protected]>Reviewed-by Markus Armbruster <[email protected]>---
v5: add R-b
v4: no change
v3: use inline \xff byte rather than %c, add comment--- tests/libqtest.c | 8 ++++++++ tests/test-qga.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-)tests/libqtest.c +8
-0@@ -446,6 +446,14 @@ void qmp_fd_sendv(int fd, const char *fmt, va_list ap)va_list ap_copy;QObject *qobj; +/* qobject_from_jsonv() silently eats leading 0xff as invalid +* JSON, but we want to test sending them over the wire to force +* resyncs */ +if (*fmt =='\377' ) { +socket_send (fd, fmt,1 ); + fmt++; + } +/* Going through qobject ensures we escape strings properly. * This seemingly unnecessary copy is required in case va_list * is an array type. tests/test-qga.c +27
-7@@ -146,14 +146,23 @@ static void test_qga_sync_delimited(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync-delimited'," -" 'arguments': {'id': %u } }" ,0xff , r); + cmd =g_strdup_printf ("\xff{'execute': 'guest-sync-delimited'," +" 'arguments': {'id': %u } }" , r);qmp_fd_send (fixture->fd, cmd);g_free (cmd); - v =read (fixture->fd, &c,1 ); - g_assert_cmpint(v, ==, 1); - g_assert_cmpint(c, ==, 0xff); +/* +* Read and ignore garbage until resynchronized. +* +* TODO: The server shouldn't emit so much garbage (among other +* things, it loudly complains about the client's \xff being +* invalid JSON, even though it is a documented part of the +* handshake. +*/ +do { + v =read (fixture->fd, &c,1 ); + g_assert_cmpint(v, ==, 1); + }while (c !=0xff ); ret =qmp_fd_receive (fixture->fd);g_assert_nonnull (ret);@@ -172,8 +181,19 @@ static void test_qga_sync(gconstpointer fix)QDict *ret;gchar *cmd; - cmd =g_strdup_printf ("%c{'execute': 'guest-sync'," -" 'arguments': {'id': %u } }" ,0xff , r); +/* +* TODO guest-sync is inherently limited: we cannot distinguish +* failure caused by reacting to garbage on the wire prior to this +* command, from failure of this actual command. Clients are +* supposed to be able to send a raw '\xff' byte to at least +* re-synchronize the server's parser prior to this command, but +* we are not in a position to test that here because (at least +* for now) it causes the server to issue an error message about +* invalid JSON. Testing of '\xff' handling is done in +* guest-sync-delimited instead. +*/ + cmd =g_strdup_printf ("{'execute': 'guest-sync'," +" 'arguments': {'id': %u } }" , r); ret =qmp_fd (fixture->fd, cmd);g_free (cmd);Signature · 1 line
2.9.3
Re: [Qemu-devel] [Research] Strato HiDrive as a Dropbox Replacement?
In reply to a message not in the archiveQuoted 7 lines · On Tue, 2 May 2017 15:11:20 +0200 Kai Wagner <[email protected]> wrote:
Quoted 4 lines · Kai Dupke
Quoted 2 lines · Lenz Grimmer
I don't, as none of these services store my data in encrypted form by default...
Any service you know where this (encryption) is handled properly?
https://www.teamdrive.com/en/downloads/ -> Commercial and not open, but to answer your questions -> yes.
Presumably anything using Ceph which includes Amazon according to this article http://searchstorage.techtarget.com/definition/Ceph
Thanks
Michal
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
In reply to Michael RothQuoted 36 lines · Michael Roth
Quoting Michael Roth (2017-05-02 11:46:36)
Quoted 27 lines
Quoting Eric Blake (2017-04-27 16:58:21)
Quoted 14 lines
Commit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending
0xffto QGA to force the parser to reset. But this aspect of the test has never actually done anything: theqmp_fd()call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the0xffbyte from the string sent to QGA, thus never resetting the QGA parser.An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
Quoted 11 lines
But fixing
qmp_fd()to actually send0xffover the wire is not all we have to do - the actual QMP parser loudly complains that0xffis not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check0xffbehavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.Quoted 7 lines
The full re-sync sequence is actually to perform that process, check if the response matches the client-provided sync token, and then repeat the procedure if it doesn't (in the odd case that a previous client initiated a guest-sync-delimited sequence and never consumed the response). The current implementation only performs one iteration so it's not quite a full implementation of the documentation procedure.
Quoted 3 lines
Well, to be more accurate it's a full implementation of the documented procedure, it's just that the procedure isn't fully documented properly. I'll send a patch to address that.
Good.
Quoted 4 lines
Quoted 4 lines
For the immediate purpose of improving the handling to deal with the 0xFF-generated error the patch seems sound though, maybe just something worth noting in the commit msg or comments so that we might eventually test the full procedure.
Feel free to suggest something for me to add to the commit message.
Quoted 3 lines
Quoted 3 lines
In any case:
Reviewed-by Michael Roth <[email protected]>
Noted, thanks!
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
Quoting Markus Armbruster (2017-05-03 03:57:41)
Quoted 42 lines
Quoted 36 lines · Michael Roth
Quoting Michael Roth (2017-05-02 11:46:36)
Quoted 27 lines
Quoting Eric Blake (2017-04-27 16:58:21)
Quoted 14 lines
Commit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending
0xffto QGA to force the parser to reset. But this aspect of the test has never actually done anything: theqmp_fd()call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the0xffbyte from the string sent to QGA, thus never resetting the QGA parser.An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
Quoted 11 lines
But fixing
qmp_fd()to actually send0xffover the wire is not all we have to do - the actual QMP parser loudly complains that0xffis not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check0xffbehavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.Quoted 7 lines
The full re-sync sequence is actually to perform that process, check if the response matches the client-provided sync token, and then repeat the procedure if it doesn't (in the odd case that a previous client initiated a guest-sync-delimited sequence and never consumed the response). The current implementation only performs one iteration so it's not quite a full implementation of the documentation procedure.
Quoted 3 lines
Well, to be more accurate it's a full implementation of the documented procedure, it's just that the procedure isn't fully documented properly. I'll send a patch to address that.
Quoted 8 lines
Good.
Quoted 4 lines
Quoted 4 lines
For the immediate purpose of improving the handling to deal with the 0xFF-generated error the patch seems sound though, maybe just something worth noting in the commit msg or comments so that we might eventually test the full procedure.
Feel free to suggest something for me to add to the commit message.
Maybe change:
"which matches the documented actions that a real QGA client
is supposed to do."
to
"which is compatible with the documented actions that a real
QGA client is supposed to do."
and add the following comment to test_qga_sync_delimited
/*
* Note that the full reset sequence would involve checking the
* response of guest-sync-delimited and repeating the loop if
* 'id' field of the response does not match the 'id' field of
* the request. Testing this fully would require inserting
* garbage in the response stream and is left as a future test
* to implement.
*/
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
In any case:
Reviewed-by Michael Roth <[email protected]>Noted, thanks!
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
Quoted 64 lines · Michael Roth
Quoting Markus Armbruster (2017-05-03 03:57:41)
Quoted 42 lines
Quoted 36 lines · Michael Roth
Quoting Michael Roth (2017-05-02 11:46:36)
Quoted 27 lines
Quoting Eric Blake (2017-04-27 16:58:21)
Quoted 14 lines
Commit 62c39b3 introduced test-qga, and at face value, appears to be testing the 'guest-sync' behavior that is recommended for guests in sending
0xffto QGA to force the parser to reset. But this aspect of the test has never actually done anything: theqmp_fd()call chain converts its string argument into QObject, then converts that QObject back to the actual string that is sent over the wire - and the conversion process silently drops the0xffbyte from the string sent to QGA, thus never resetting the QGA parser.An upcoming patch will get rid of the wasteful round trip through QObject, at which point the string in test-qga will be directly sent over the wire.
Quoted 11 lines
But fixing
qmp_fd()to actually send0xffover the wire is not all we have to do - the actual QMP parser loudly complains that0xffis not valid JSON, and sends an error message _prior_ to actually parsing the 'guest-sync' or 'guest-sync-delimited' command. With 'guest-sync', we cannot easily tell if this error message is a result of our command - which is WHY we invented the 'guest-sync-delimited' command. So for the testsuite, fix things to only check0xffbehavior on 'guest-sync-delimited', and to loop until we've consumed all garbage prior to the requested delimiter, which matches the documented actions that a real QGA client is supposed to do.Quoted 7 lines
The full re-sync sequence is actually to perform that process, check if the response matches the client-provided sync token, and then repeat the procedure if it doesn't (in the odd case that a previous client initiated a guest-sync-delimited sequence and never consumed the response). The current implementation only performs one iteration so it's not quite a full implementation of the documentation procedure.
Quoted 3 lines
Well, to be more accurate it's a full implementation of the documented procedure, it's just that the procedure isn't fully documented properly. I'll send a patch to address that.
Quoted 8 lines
Good.
Quoted 4 lines
Quoted 4 lines
For the immediate purpose of improving the handling to deal with the 0xFF-generated error the patch seems sound though, maybe just something worth noting in the commit msg or comments so that we might eventually test the full procedure.
Feel free to suggest something for me to add to the commit message.
Maybe change:
"which matches the documented actions that a real QGA client
is supposed to do."to
"which is compatible with the documented actions that a real
QGA client is supposed to do."and add the following comment to
test_qga_sync_delimited
Quoted 8 lines
/*
* Note that the full reset sequence would involve checking the
* response of guest-sync-delimited and repeating the loop if
* 'id' field of the response does not match the 'id' field of
* the request. Testing this fully would require inserting
* garbage in the response stream and is left as a future test
* to implement.
*/
Eric, want me to squash that in?
Re: [Qemu-devel] [PATCH v5 10/10] test-qga: Actually test 0xff sync bytes
Quoted 23 lines · Markus Armbruster
Quoted 14 lines
Quoted 1 line
Feel free to suggest something for me to add to the commit message.
Maybe change:
"which matches the documented actions that a real QGA client
is supposed to do."to
"which is compatible with the documented actions that a real
QGA client is supposed to do."and add the following comment to
test_qga_sync_delimitedQuoted 8 lines
/*
* Note that the full reset sequence would involve checking the
* response of guest-sync-delimited and repeating the loop if
* 'id' field of the response does not match the 'id' field of
* the request. Testing this fully would require inserting
* garbage in the response stream and is left as a future test
* to implement.
*/
Quoted 1 line
Eric, want me to squash that in?
Yes, those changes are reasonable.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
In reply to Markus ArmbrusterQuoted 10 lines · Markus Armbruster
Quoted 3 lines
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>
Quoted 7 lines
The tests and qobject parts had
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
You can keep my R-by, I just reviewed the combined patch.
Berto
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
Quoted 13 lines · Alberto Garcia
Quoted 12 lines · Markus Armbruster
Quoted 3 lines
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>The tests and qobject parts had
Quoted 7 lines
Quoted 5 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
You can keep my R-by, I just reviewed the combined patch.
Done. Thanks!
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [Qemu-devel] [PATCH v5 06/10] qobject: Use simpler QDict/QList scalar insertion macros
In reply to Alberto GarciaQuoted 13 lines · Alberto Garcia
Quoted 12 lines · Markus Armbruster
Quoted 3 lines
v5: rebase to master (Coccinelle found a couple new spots), squash 3 patches into 1, adjust R-b to only list Markus (while there were other reviews on the pre-squashed patches, Markus was the only one on all 3)
The block: part had
Reviewed-by Stefan Hajnoczi <[email protected]>Reviewed-by Alberto Garcia <[email protected]>The tests and qobject parts had
Quoted 7 lines
Quoted 5 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Richard, Stefan, Alberto, Philippe, let me know if you'd like me to convert your R-by of parts to an Acked-by of the combined patch. Feel free to review the combined patch, of course.
You can keep my R-by, I just reviewed the combined patch.
Done. Thanks!